Use the SA_NOCLDWAIT sigaction() flag to disable the creation of zombie processes. This leaves no reason to wait() on children, so remove the reaping routine. Previously, deadq entries were removed in reapchild(). Move deadq removal into markit() after SIGKILL is sent.
Details
- Reviewers
markj - Commits
- rGfe233250d6fd: syslogd: Do not reap child processes
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
usr.sbin/syslogd/syslogd.c | ||
---|---|---|
3202–3203 | Now that there are no zombies, how do you know that it is safe to kill this PID? It might have been recycled. Once you convert to using process descriptors, you can use pdkill() to remove the problem, but that happens later in the patch stack. Or am I missing something? |
usr.sbin/syslogd/syslogd.c | ||
---|---|---|
3202–3203 |
What you're describing is correct. The PID will be recycled and then we're sending SIGKILL to an entirely unrelated process. It slipped my mind that the PID would be recycled. I can't think of a simple way of verifying that the given PID is a child of syslogd. |
usr.sbin/syslogd/syslogd.c | ||
---|---|---|
3202–3203 | I think you have to defer the use of SA_NOCLDWAIT until after process descriptors are introduced. |
Apply this patch after we have procdescs so we don't accidentally kill() a recycled PID.
Nice cleanup.
usr.sbin/syslogd/syslogd.c | ||
---|---|---|
847 | A comment explaining how syslogd handles children would be better. |
Update after rebase. A comment for child process handling is added in https://reviews.freebsd.org/D41433