]> git.ipfire.org Git - thirdparty/systemd.git/commit
core/service: when resetting PID also reset known flag
authorMichal Sekletar <msekleta@redhat.com>
Mon, 22 May 2023 15:44:30 +0000 (17:44 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 23 May 2023 07:27:56 +0000 (09:27 +0200)
commitff32060f2ed37b68dc26256b05e2e69013b0ecfe
treef7fcfee2668dcf42903bcc65f5c67d27355f7633
parentb1f17f78e3453aae83fbb258c155fc63a8788af7
core/service: when resetting PID also reset known flag

Re-watching pids on cgroup v1 (needed because of unreliability of cgroup
empty notifications in containers) is handled bellow at the end of
service_sigchld_event() and depends on value main_pid_known flag.

In CentOS Stream 8 container on cgroup v1 the stop action would get stuck
indefinitely on unit like this,

$ cat /run/systemd/system/foo.service
[Service]
ExecStart=/bin/bash -c 'trap "nohup sleep 1 & exit 0" TERM;  sleep infinity'
ExecStop=/bin/bash -c 'kill -s TERM $MAINPID'
TimeoutSec=0

However, upstream works "fine" because in upstream version of systemd we
actually never wait on processes killed in containers and proceed
immediately to sending SIGKILL hence re-watching of pids in the cgroup
is not necessary. But for the sake of correctness we should merge the
patch also upstream.
src/core/service.c