HomeFreeBSD

reapkill: handle possible pid reuse after the pid was recorded as signalled

Description

reapkill: handle possible pid reuse after the pid was recorded as signalled

Nothing prevents the signalled process from exiting, and then other
process among eligible for signalling to reuse the exited process pid.
In this case, presence of the pid in the 'pids' unr set prevents it from
getting the deserved signal.

Handle it by marking each process with the new flag P2_REAPKILLED when
we are about to send the signal. If the process pid is present in the
pids unr, but the struct proc is not marked with P2_REAPKILLED, we must
send signal to the pid again.

The use of the flag relies on the global sapblk preventing parallel
reapkills.

The pids unr must be used to clear the flags to all signalled processes.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D40089

Details

Provenance
kibAuthored on May 12 2023, 10:36 PM
Reviewer
markj
Differential Revision
D40089: reapkill: handle possible pid reuse after the pid was recorded as signalled
Parents
rGea95173dbb3b: unr(9): document iterators
Branches
Unknown
Tags
Unknown