]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/mount.c
core: reduce the number of stalled PIDs from the watched processes list when possible
authorFranck Bui <fbui@suse.com>
Mon, 18 Mar 2019 19:59:36 +0000 (20:59 +0100)
committerFranck Bui <fbui@suse.com>
Wed, 20 Mar 2019 09:51:49 +0000 (10:51 +0100)
commitf75f613d259e9332be8e9657fa37e73f7aabcb8a
tree7900f402ac0b87da60b90e6c429a93a5abd8a621
parent4d05154600f64e9d5c9800ff9f61167fe80a08ba
core: reduce the number of stalled PIDs from the watched processes list when possible

Some PIDs can remain in the watched list even though their processes have
exited since a long time. It can easily happen if the main process of a forking
service manages to spawn a child before the control process exits for example.

However when a pid is about to be mapped to a unit by calling unit_watch_pid(),
the caller usually knows if the pid should belong to this unit exclusively: if
we just forked() off a child, then we can be sure that its PID is otherwise
unused. In this case we take this opportunity to remove any stalled PIDs from
the watched process list.

If we learnt about a PID in any other form (for example via PID file, via
searching, MAINPID= and so on), then we can't assume anything.
src/core/cgroup.c
src/core/dbus-scope.c
src/core/manager.c
src/core/manager.h
src/core/mount.c
src/core/service.c
src/core/socket.c
src/core/swap.c
src/core/unit.c
src/core/unit.h
src/test/test-watch-pid.c