Page MenuHomeFreeBSD

D58407.id182772.diff
No OneTemporary

D58407.id182772.diff

diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1575,12 +1575,29 @@
p, pd, pd->pd_flags));
sx_xlock(&proctree_lock);
+ if ((pd->pd_flags & PDF_EXITED) != 0) {
+ if ((options & WEXITED) == 0) {
+ error = ESRCH;
+ goto exit_tree_locked;
+ }
+ *status = KW_EXITCODE(pd->pd_xexit, pd->pd_xsig);
+ if (wrusage != NULL) {
+ memcpy(wrusage, &pd->pd_wrusage,
+ sizeof(*wrusage));
+ }
+ if (siginfo != NULL) {
+ memcpy(siginfo, &pd->pd_siginfo,
+ sizeof(*siginfo));
+ }
+ goto exit_tree_locked;
+ }
p = pd->pd_proc;
if (p == NULL) {
error = ESRCH;
goto exit_tree_locked;
}
PROC_LOCK(p);
+ MPASS(p->p_state != PRS_ZOMBIE);
error = p_canwait(td, p);
if (error != 0)
@@ -1593,11 +1610,6 @@
wait_fill_siginfo(p, siginfo);
wait_fill_wrusage(p, wrusage);
- if (p->p_state == PRS_ZOMBIE) {
- proc_reap(td, p, status, options);
- goto exit_unlocked;
- }
-
if (wait6_check_alive(td, options, p, status, siginfo))
goto exit_unlocked;
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
@@ -295,7 +295,10 @@
KASSERT(pd->pd_fpcount > 0, ("%s: closed procdesc %p", __func__, pd));
pd->pd_flags |= PDF_EXITED;
- pd->pd_xstat = KW_EXITCODE(p->p_xexit, p->p_xsig);
+ pd->pd_xexit = p->p_xexit;
+ pd->pd_xsig = p->p_xsig;
+ wait_fill_siginfo(p, &pd->pd_siginfo);
+ wait_fill_wrusage(p, &pd->pd_wrusage);
selwakeup(&pd->pd_selinfo);
KNOTE_LOCKED(&pd->pd_selinfo.si_note, NOTE_EXIT | NOTE_PDSIGCHLD);
@@ -509,7 +512,7 @@
/* Report exit status */
if ((kn->kn_fflags & NOTE_EXIT) != 0)
- kn->kn_data = pd->pd_xstat;
+ kn->kn_data = KW_EXITCODE(pd->pd_xexit, pd->pd_xsig);
/* Process is gone, so flag the event as finished. */
if ((event & NOTE_REAP) != 0 ||
diff --git a/sys/sys/procdesc.h b/sys/sys/procdesc.h
--- a/sys/sys/procdesc.h
+++ b/sys/sys/procdesc.h
@@ -72,9 +72,14 @@
* In-flight data and notification of events.
*/
int pd_flags; /* (p) PD_ flags. */
- u_short pd_xstat; /* (p) Exit status. */
struct selinfo pd_selinfo; /* (p) Event notification. */
struct mtx pd_lock; /* Protect data + events. */
+
+ /* Exit status. */
+ u_int pd_xexit;
+ u_int pd_xsig;
+ struct __wrusage pd_wrusage;
+ siginfo_t pd_siginfo;
};
/*

File Metadata

Mime Type
text/plain
Expires
Fri, Jul 31, 4:38 AM (19 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35767655
Default Alt Text
D58407.id182772.diff (2 KB)

Event Timeline