Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145523226
D17589.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D17589.id.diff
View Options
Index: head/sys/kern/sys_procdesc.c
===================================================================
--- head/sys/kern/sys_procdesc.c
+++ head/sys/kern/sys_procdesc.c
@@ -312,8 +312,8 @@
pd = p->p_procdesc;
PROCDESC_LOCK(pd);
- KASSERT((pd->pd_flags & PDF_CLOSED) == 0 || p->p_pptr == initproc,
- ("procdesc_exit: closed && parent not init"));
+ KASSERT((pd->pd_flags & PDF_CLOSED) == 0 || p->p_pptr == p->p_reaper,
+ ("procdesc_exit: closed && parent not reaper"));
pd->pd_flags |= PDF_EXITED;
pd->pd_xstat = KW_EXITCODE(p->p_xexit, p->p_xsig);
@@ -361,7 +361,8 @@
/*
* procdesc_close() - last close on a process descriptor. If the process is
* still running, terminate with SIGKILL (unless PDF_DAEMON is set) and let
- * init(8) clean up the mess; if not, we have to clean up the zombie ourselves.
+ * its reaper clean up the mess; if not, we have to clean up the zombie
+ * ourselves.
*/
static int
procdesc_close(struct file *fp, struct thread *td)
@@ -410,12 +411,12 @@
procdesc_free(pd);
/*
- * Next, reparent it to init(8) so that there's someone
- * to pick up the pieces; finally, terminate with
- * prejudice.
+ * Next, reparent it to its reaper (usually init(8)) so
+ * that there's someone to pick up the pieces; finally,
+ * terminate with prejudice.
*/
p->p_sigparent = SIGCHLD;
- proc_reparent(p, initproc);
+ proc_reparent(p, p->p_reaper);
if ((pd->pd_flags & PDF_DAEMON) == 0)
kern_psignal(p, SIGKILL);
PROC_UNLOCK(p);
Index: head/tests/sys/kern/reaper.c
===================================================================
--- head/tests/sys/kern/reaper.c
+++ head/tests/sys/kern/reaper.c
@@ -28,6 +28,7 @@
__FBSDID("$FreeBSD$");
#include <sys/procctl.h>
+#include <sys/procdesc.h>
#include <sys/wait.h>
#include <atf-c.h>
@@ -740,6 +741,40 @@
ATF_REQUIRE_EQ(0, r);
}
+ATF_TC_WITHOUT_HEAD(reaper_pdfork);
+ATF_TC_BODY(reaper_pdfork, tc)
+{
+ struct procctl_reaper_status st;
+ pid_t child, grandchild, parent, pid;
+ int pd, r, status;
+
+ parent = getpid();
+ r = procctl(P_PID, parent, PROC_REAP_ACQUIRE, NULL);
+ ATF_REQUIRE_EQ(r, 0);
+
+ child = pdfork(&pd, 0);
+ ATF_REQUIRE(child != -1);
+ if (child == 0) {
+ grandchild = pdfork(&pd, 0);
+ if (grandchild == -1)
+ _exit(1);
+ if (grandchild == 0)
+ pause();
+ _exit(0);
+ }
+ pid = waitpid(child, &status, 0);
+ ATF_REQUIRE_EQ(pid, child);
+ r = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
+ ATF_REQUIRE_EQ(r, 0);
+
+ r = procctl(P_PID, parent, PROC_REAP_STATUS, &st);
+ ATF_REQUIRE_EQ(r, 0);
+ ATF_CHECK((st.rs_flags & REAPER_STATUS_OWNED) != 0);
+ ATF_CHECK(st.rs_reaper == parent);
+ ATF_CHECK(st.rs_children == 1);
+ ATF_CHECK(st.rs_descendants == 1);
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -754,5 +789,6 @@
ATF_TP_ADD_TC(tp, reaper_kill_empty);
ATF_TP_ADD_TC(tp, reaper_kill_normal);
ATF_TP_ADD_TC(tp, reaper_kill_subtree);
+ ATF_TP_ADD_TC(tp, reaper_pdfork);
return (atf_no_error());
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 21, 11:25 PM (3 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28929083
Default Alt Text
D17589.id.diff (2 KB)
Attached To
Mode
D17589: Reparent to the process' reaper when a procdesc is closed.
Attached
Detach File
Event Timeline
Log In to Comment