|
|
Log in / Subscribe / Register

Changing Fedora's shutdown timeouts

Changing Fedora's shutdown timeouts

Posted Jan 19, 2023 13:02 UTC (Thu) by kleptog (subscriber, #1183)
In reply to: Changing Fedora's shutdown timeouts by NYKevin
Parent article: Changing Fedora's shutdown timeouts

When I see this issue it's mainly caused by container-like constructions where the parent process in the "container" gains PID1 signal protections. Namely, a PID1 process may not be killed by a default signal handler. Since most processes don't install a signal handler for SIGKILL, such processes become immune to SIGKILL. Of course, many programs don't install a SIGTERM handler either, but that's somewhat more common.

This is the reason many container guides suggest using something like systemd, supervisord, dumb-init, tini, etc as the root process because those *do* install a SIGKILL handler which properly exits. The symptom is pretty clear: killing your container takes ages.

Of course, if SIGKILL fails, the entire cgroup gets nuked eventually, and there's no immunity from that.


to post comments

Changing Fedora's shutdown timeouts

Posted Jan 27, 2023 11:19 UTC (Fri) by intelfx (subscriber, #130118) [Link] (6 responses)

> Since most processes don't install a signal handler for SIGKILL, such processes become immune to SIGKILL. Of course, many programs don't install a SIGTERM handler either, but that's somewhat more common.
>
> This is the reason many container guides suggest using something like systemd, supervisord, dumb-init, tini, etc as the root process because those *do* install a SIGKILL handler which properly exits. The symptom is pretty clear: killing your container takes ages.

There is something wrong. signal(7) says (in the Standard signals) that “the signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored”.

That’s the whole point of SIGKILL.

Changing Fedora's shutdown timeouts

Posted Jan 27, 2023 12:20 UTC (Fri) by Wol (subscriber, #4433) [Link]

Forgive me if I'm wrong, but - just as access rights do not apply to user 0 - signals do not apply to pid 1?

SIGKILL etc may be untrappable, but it's down to pid 1 to enforce that. Ergo, you cannot send pid 1 a SIGKILL and expect it to work.

Cheers,
Wol

Changing Fedora's shutdown timeouts

Posted Jan 28, 2023 3:38 UTC (Sat) by mathstuf (subscriber, #69389) [Link] (4 responses)

PID 1 only receives signals for which it installs handlers. It's a bit special in that way. When "random executable X" is launched directly in a container with a PID namespace, it becomes that namespace's PID 1 and since SIGKILL handlers are generally only done in programs *expecting* to be PID 1, these processes therefore become unkillable.

Changing Fedora's shutdown timeouts

Posted Jan 28, 2023 12:49 UTC (Sat) by izbyshev (subscriber, #107996) [Link] (3 responses)

There are no "SIGKILL handlers" (and SIGSTOP handlers). It's impossible to change signal disposition for SIGKILL and SIGSTOP[1], as intelfx pointed out, so no init process (whether global or from a pid namespace) can change the effects of these signals. They can't be sent to the global init because the kernel explicitly disallows that[2]. For pid namespace inits, SIGKILL and SIGSTOP are allowed if sent from an ancestor pid namespace[3].

[1] https://elixir.bootlin.com/linux/v6.1.8/source/kernel/sig...
[2] https://elixir.bootlin.com/linux/v6.1.8/source/kernel/sig...
[3] https://elixir.bootlin.com/linux/v6.1.8/source/kernel/sig...

Changing Fedora's shutdown timeouts

Posted Jan 28, 2023 16:30 UTC (Sat) by kleptog (subscriber, #1183) [Link] (2 responses)

Thanks. I'd just like to say I find the PID1 signal handling somewhat underdocumented. The clearest thing I could find was this LKML message[1] from 2008.

[1] https://lwn.net/Articles/312721/

So it's true that init processes cannot be killed by unhandled signals, and that usually what prevents containers inits from dying on SIGTERM. But that's not what protects them from SIGKILL, that's handled on the other end. What happens if a container init receives a SIGSEGV due to a memory fault but has no handler installed wasn't immediately clear to me (I think the force mechanism will cause it to die anyway, not sure).

Changing Fedora's shutdown timeouts

Posted Feb 5, 2023 19:45 UTC (Sun) by flussence (guest, #85566) [Link] (1 responses)

IIRC in a namespace, if PID1 is SIGKILLed (or just exits some other way), what happens is every *other* PID in there gets SIGKILLed.

And that's part of the contract which "Container-init must behave like global-init to processes within the container" from that link entails - when you kill PID1 on bare metal the system stops.

Changing Fedora's shutdown timeouts

Posted Feb 26, 2023 16:30 UTC (Sun) by nix (subscriber, #2304) [Link]

> And that's part of the contract which "Container-init must behave like global-init to processes within the container" from that link entails

This seems to conflict badly with the reality which has random programs running as PID 1 in single-service containers. Hardly any of these programs are expecting ever to suddenly become an init...


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds