Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
manager: always reap first the process for which we already got SIGCHLD
If we get a SIGCHLD we enable and eventually dispatch sigchld_event_source where we actually reap the process. We received SIGCHLD for the specific PID so wait for that process first. Motivation to do this is to prevent problem due to our state machine for mount units relying on the fact that we always dispatch mountinfo notifications before dispatching sigchld handler for the mount. Previously, this was racy because we might have called manager_dispatch_sigchld() for completely unrelated process but we would actually reap the mount process which completed in the meantime. sigchld handler for the mount unit would then fail the mount unit because we haven't dispatched mountinfo notification yet. event| mount kernel PID 1 ------------------------------------------------------------------------ 1 | forks off mount as PID x ------------------------------------------------------------------------ 2 | receives SIGCHLD for PID y ------------------------------------------------------------------------ 3 | enables sigchld_event_source ------------------------------------------------------------------------ 4 | dispatches sigchld_event_source ------------------------------------------------------------------------ 5 | mount() mountinfo_notif ------------------------------------------------------------------------ 6 | exit() ------------------------------------------------------------------------ 7 | calls waitid() with P_ALL ------------------------------------------------------------------------ 8 | calls sigchld_handler for mount ------------------------------------------------------------------------ 9 | fails the mount unit since | mountinfo_notif wasn't | processed yet ------------------------------------------------------------------------ Fixes systemd#10872
- Loading branch information