Page MenuHomeFreeBSD

D58123.id181717.diff
No OneTemporary

D58123.id181717.diff

diff --git a/lib/libsys/kqueue.2 b/lib/libsys/kqueue.2
--- a/lib/libsys/kqueue.2
+++ b/lib/libsys/kqueue.2
@@ -587,11 +587,19 @@
and returns when the associated process performs one or more of the
requested events.
The events to monitor are:
-.Bl -tag -width "Dv NOTE_EXIT"
+.Bl -tag -width "Dv NOTE_PDSIGCHLD"
.It Dv NOTE_EXIT
The process has exited.
The exit status will be stored in
.Va data .
+.It Dv NOTE_PDSIGCHLD
+Activates on events that are reported through
+.Xr pdwait 2
+on the process descriptor.
+After the event is reported, the
+.Xr pdwait 2
+can be called to obtain the information about the process
+status change.
.El
.Pp
On return,
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -3688,6 +3688,7 @@
*/
p->p_pptr->p_flag |= P_STATCHILD;
wakeup(p->p_pptr);
+ procdesc_jobstate(p);
ps = p->p_pptr->p_sigacts;
mtx_lock(&ps->ps_mtx);
diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c
--- a/sys/kern/sys_procdesc.c
+++ b/sys/kern/sys_procdesc.c
@@ -64,6 +64,7 @@
#include <sys/param.h>
#include <sys/capsicum.h>
+#include <sys/event.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/filedesc.h>
@@ -310,7 +311,7 @@
return (1);
}
selwakeup(&pd->pd_selinfo);
- KNOTE_LOCKED(&pd->pd_selinfo.si_note, NOTE_EXIT);
+ KNOTE_LOCKED(&pd->pd_selinfo.si_note, NOTE_EXIT | NOTE_PDSIGCHLD);
PROCDESC_UNLOCK(pd);
/* Wakeup all waiters for this procdesc' process exit. */
@@ -318,6 +319,21 @@
return (0);
}
+void
+procdesc_jobstate(struct proc *p)
+{
+ struct procdesc *pd;
+
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+ pd = p->p_procdesc;
+ if (pd == NULL)
+ return;
+
+ PROCDESC_LOCK(pd);
+ KNOTE_LOCKED(&pd->pd_selinfo.si_note, NOTE_PDSIGCHLD);
+ PROCDESC_UNLOCK(pd);
+}
+
/*
* When a process descriptor is reaped, perhaps as a result of close(), release
* the process's reference on the process descriptor.
@@ -479,7 +495,7 @@
kn->kn_fflags |= event;
/* Process is gone, so flag the event as finished. */
- if (event == NOTE_EXIT) {
+ if ((event & NOTE_EXIT) != 0) {
kn->kn_flags |= EV_EOF | EV_ONESHOT;
if (kn->kn_fflags & NOTE_EXIT)
kn->kn_data = pd->pd_xstat;
diff --git a/sys/sys/event.h b/sys/sys/event.h
--- a/sys/sys/event.h
+++ b/sys/sys/event.h
@@ -202,9 +202,12 @@
/*
* data/hint flags for EVFILT_PROC and EVFILT_PROCDESC, shared with userspace
*/
-#define NOTE_EXIT 0x80000000 /* process exited */
-#define NOTE_FORK 0x40000000 /* process forked */
-#define NOTE_EXEC 0x20000000 /* process exec'd */
+#define NOTE_EXIT 0x80000000 /* proc/procdesc: process
+ exited */
+#define NOTE_FORK 0x40000000 /* proc: process forked */
+#define NOTE_EXEC 0x20000000 /* proc: process exec'd */
+#define NOTE_PDSIGCHLD 0x10000000 /* procdesc: pdwait() info
+ available */
#define NOTE_PCTRLMASK 0xf0000000 /* mask for hint bits */
#define NOTE_PDATAMASK 0x000fffff /* mask for pid */
diff --git a/sys/sys/procdesc.h b/sys/sys/procdesc.h
--- a/sys/sys/procdesc.h
+++ b/sys/sys/procdesc.h
@@ -102,6 +102,7 @@
* In-kernel interfaces to process descriptors.
*/
int procdesc_exit(struct proc *);
+void procdesc_jobstate(struct proc *p);
int kern_pdgetpid(struct thread *, int fd, const cap_rights_t *,
pid_t *pidp);
void procdesc_new(struct proc *, int);

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 16, 1:13 AM (12 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35120978
Default Alt Text
D58123.id181717.diff (3 KB)

Event Timeline