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.
This commit is contained in:
+1
-1
@@ -678,7 +678,7 @@ typedef enum UnitNotifyFlags {
|
||||
|
||||
void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlags flags);
|
||||
|
||||
int unit_watch_pid(Unit *u, pid_t pid);
|
||||
int unit_watch_pid(Unit *u, pid_t pid, bool exclusive);
|
||||
void unit_unwatch_pid(Unit *u, pid_t pid);
|
||||
void unit_unwatch_all_pids(Unit *u);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user