procdesc: report NOTE_PDSIGCHLD for traced and stopped process

on attach of the knote.  It is same as for NOTE_EXIT when attaching to
the exiting process.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58327
This commit is contained in:
Konstantin Belousov committed 2026-07-20 05:00:02 +03:00
1 parent 3f88f6b899
commit b328975b9d
1 file changed
+12 -3
+12 -3
View File
@@ -493,16 +493,25 @@ static int
procdesc_kqops_event(struct knote *kn, long hint)
{
struct procdesc *pd;
struct proc *p;
u_int event;
pd = kn->kn_fp->f_data;
if (hint == 0) {
/*
* Initial test after registration. Generate notes in
* case the process already terminated before registration.
* case the process already terminated before
* registration, or is stopped, or traced, with an event
* pending.
*/
event = (pd->pd_flags & PDF_EXITED) != 0 ? (NOTE_EXIT |
NOTE_PDSIGCHLD) : 0;
p = pd->pd_proc;
if ((pd->pd_flags & PDF_EXITED) != 0)
event = NOTE_EXIT | NOTE_PDSIGCHLD;
else if ((atomic_load_int(&p->p_flag) & (P_STOPPED_SIG |
P_STOPPED_TRACE)) != 0)
event = NOTE_PDSIGCHLD;
else
event = 0;
} else {
/* Mask off extra data. */
event = (u_int)hint & NOTE_PCTRLMASK;