What happens to a daemon without a "K" link in /etc/rcX.d/

What happens to processes started by init through an init script, if that script does not have a corresponding K entry in (for example) /etc/rc0.d/?

For example, the following script started a daemonized process:

-rwxrwxr-x. 1 root root 3.3K Jul 16 11:48 /etc/rc3.d/S99foobar

There is no corresponding link (eg, /etc/rc0.d/K99foobar) to handle terminating those processes at shutdown/reboot time.

Do these processes just receive a SIGTERM, followed by a SIGKILL, from init when they're the last things running? Or is init smart enough to call /etc/init.d/foobar stop?


If you watch your shutdown process carefully, you will see, after virtually everything has been done, that init will kill anything that's still running.

On a Red Hat/CentOS 6 system you'll see:

Sending all processes the TERM signal...

followed a few seconds later by

Sending all processes the KILL signal...

Anything that had not been shut down by then will be killed. This is in the /etc/rc.d/init.d/halt script which is the final script run at system shutdown.

After this runs, halt begins unmounting filesystems and doing other pre-shutdown final cleanup, then finally actually halts or reboots the system.

All other distributions using upstart or SysVinit do something similar.

Note that this issue does not arise with systemd, because it is always aware of what services it has started.


In the end, after taking down everything that can be brought down nicely, everything remaining receives a "kill -9".