Is there any way to make a program that cannot be interrupted (an uninterrupted program)? By that, I mean a process that can\'t be terminated by any signal, kill comma
On Linux, it is possible to avoid being killed by one of two ways:
init
(PID 1). init
ignores all signals that it does not catch, even normally unblockable ones like SIGSTOP
and SIGKILL
.D
(uninterruptible wait) state.For 2.
, one common way to end up in D
state is to attempt to access some hardware that is not responding. Particularly on older versions of Linux, the process would become stuck in kernel mode, and not respond to any signals until the kernel gave up on the hardware (which can take quite some time!). Of course, your program can't do anything else while it's stuck like this, so it's more annoying than useful, and newer versions of Linux are starting to rectify this problem by dividing D
state into a killable state (where SIGKILL
works) and an unkillable state (where all signals are blocked).
Or, of course, you could simply load your code as a kernel module. Kernel modules can't be 'killed', only unloaded - and only if they allow themselves to be unloaded.