Page MenuHomeFreeBSD

syslogd: Do not reap child processes
ClosedPublic

Authored by jfree on Aug 10 2023, 11:02 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 3, 8:15 AM
Unknown Object (File)
Fri, May 3, 8:15 AM
Unknown Object (File)
Fri, May 3, 8:15 AM
Unknown Object (File)
Sat, Apr 27, 9:44 PM
Unknown Object (File)
Sat, Apr 27, 9:44 PM
Unknown Object (File)
Sat, Apr 27, 9:44 PM
Unknown Object (File)
Sat, Apr 27, 9:44 PM
Unknown Object (File)
Sat, Apr 27, 8:59 PM
Subscribers

Details

Summary
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.

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

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?

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.

Fix cleanup and exit code for sigaction()

Nice cleanup.

usr.sbin/syslogd/syslogd.c
847

A comment explaining how syslogd handles children would be better.

This revision is now accepted and ready to land.Aug 14 2023, 2:23 PM

Update after rebase. A comment for child process handling is added in https://reviews.freebsd.org/D41433

This revision now requires review to proceed.Aug 14 2023, 3:45 PM

A comment for child process handling is added in https://reviews.freebsd.org/D41433

Thank you.

This revision is now accepted and ready to land.Aug 16 2023, 8:48 PM

Update after rebase conflicts

This revision now requires review to proceed.Aug 17 2023, 6:49 PM
This revision is now accepted and ready to land.Aug 23 2023, 2:35 PM
This revision was automatically updated to reflect the committed changes.