[systemd-devel] How are the running processes killed at shutdown?
Tom Gundersen
teg at jklm.no
Sat Dec 1 10:26:09 PST 2012
On Sat, Dec 1, 2012 at 4:20 PM, <tom289332 at safe-mail.net> wrote:
> How does systemd kill the running processes at shutdown?
On Sat, Dec 1, 2012 at 6:59 PM, Reindl Harald <h.reindl at thelounge.net> wrote:
>
> Am 01.12.2012 16:20, schrieb tom289332 at Safe-mail.net:
>> How does systemd kill the running processes at shutdown?
>> (I tried asking at fedoraforum.org first, but got no responses there.)
>>
>> Presumably it tries to gracefully stop all services. Is every process part of a service?
>
> finally each process get a SIGTERM and any proper written process
> wil cleanup anything he has to do and quit gracefully, this is the
> way unix works
For details about how remaining processes in a service is killed see
systemd.kill(5) [0].
Any processes still alive after all services have been terminated are
killed (in a loop) with SIGTERM/SIGKILL by systemd-shutdown [1](at
the same time remaining devices/filesystems are unmounted and
disassembled).
If your initramfs supports it [2], systemd will then pivot away from
your root partition, back into your initramfs which will again try to
kill remaining processes and unomunt remaining filesystems.
Then we give up \o/
> Presumably it tries to gracefully stop all services. Is every process part of a service?
Not necessarily (but you need to make an effort to create an exception).
> When it stops a service, it presumably runs the ExecStop of that service, but what if the service doesn't exit immediately? How long does systemd wait?
See systemd.service(5) [3], in particular TimeoutStopSec=.
HTH,
Tom
[0]: <http://www.freedesktop.org/software/systemd/man/systemd.kill.html>
[1]: <http://cgit.freedesktop.org/systemd/systemd/tree/src/core/shutdown.c>
[2]: <http://www.freedesktop.org/wiki/Software/systemd/InitrdInterface>
[3]: <http://www.freedesktop.org/software/systemd/man/systemd.service.html>
More information about the systemd-devel
mailing list