Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F164230205
D58407.id182487.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D58407.id182487.diff
View Options
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
@@ -1112,7 +1112,7 @@
atomic_add_int(&nprocs, -1);
}
-static void
+void
wait_fill_siginfo(struct proc *p, siginfo_t *siginfo)
{
PROC_LOCK_ASSERT(p, MA_OWNED);
@@ -1155,7 +1155,7 @@
*/
}
-static void
+void
wait_fill_wrusage(struct proc *p, struct __wrusage *wrusage)
{
struct rusage *rup;
@@ -1573,12 +1573,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)
@@ -1591,11 +1608,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 @@
("procdesc_exit: closed && parent not reaper"));
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);
/*
* If the process descriptor has been closed, then we have nothing
@@ -525,7 +528,7 @@
if ((event & NOTE_EXIT) != 0) {
kn->kn_flags |= EV_EOF | EV_ONESHOT;
if (kn->kn_fflags & NOTE_EXIT)
- kn->kn_data = pd->pd_xstat;
+ kn->kn_data = KW_EXITCODE(pd->pd_xexit, pd->pd_xsig);
if (kn->kn_fflags == 0)
kn->kn_flags |= EV_DROP;
return (1);
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1237,6 +1237,8 @@
void cpu_update_pcb(struct thread *);
bool curproc_sigkilled(void);
void userret(struct thread *, struct trapframe *);
+void wait_fill_siginfo(struct proc *p, struct __siginfo *siginfo);
+void wait_fill_wrusage(struct proc *p, struct __wrusage *wrusage);
void cpu_exit(struct thread *);
void exit1(struct thread *, int, int) __dead2;
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
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 30, 9:28 PM (2 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35755709
Default Alt Text
D58407.id182487.diff (3 KB)
Attached To
Mode
D58407: pdwait(2): change handling of the exited processes
Attached
Detach File
Event Timeline
Log In to Comment