Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F170151351
D58530.id.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
D58530.id.diff
View Options
diff --git a/tests/sys/kern/pdwait.c b/tests/sys/kern/pdwait.c
--- a/tests/sys/kern/pdwait.c
+++ b/tests/sys/kern/pdwait.c
@@ -216,8 +216,8 @@
}
/*
- * Even though the process descriptor is still open, there is no more process
- * to signal after pdwait() has returned.
+ * Zombie is reaped only after the last process descriptor closed. So
+ * the child still can be signalled after pdwait().
*/
ATF_TC_WITHOUT_HEAD(pdkill_after_pdwait);
ATF_TC_BODY(pdkill_after_pdwait, tc)
@@ -226,7 +226,7 @@
pid_t pid;
int r, status;
- pid = pdfork(&fdp, 0);
+ pid = pdfork(&fdp, PD_NOWAITPID);
if (pid == 0)
_exit(42);
ATF_REQUIRE_MSG(pid >= 0, "pdfork failed: %s", strerror(errno));
@@ -236,13 +236,13 @@
ATF_CHECK_EQ(r, 0);
ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 42);
- ATF_REQUIRE_ERRNO(ESRCH, pdkill(fdp, SIGTERM) < 0);
+ ATF_REQUIRE_EQ(pdkill(fdp, SIGTERM), 0);
close(fdp);
}
/*
- * Even though the process descriptor is still open, there is no more status to
+ * While the process descriptor is still open, there is still the status to
* return after a pid-based wait() function has already returned it.
*/
ATF_TC_WITHOUT_HEAD(pdwait_after_waitpid);
@@ -263,12 +263,13 @@
ATF_CHECK_EQ(pid, waited_pid);
ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 42);
- ATF_REQUIRE_ERRNO(ESRCH, pdwait(fdp, NULL, WEXITED, NULL, NULL) < 0);
+ ATF_REQUIRE_EQ(pdwait(fdp, &status, WEXITED, NULL, NULL), 0);
+ ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 42);
close(fdp);
}
-/* Called twice, waitpid should return ESRCH the second time */
+/* Called twice, waitpid should work second time */
ATF_TC_WITHOUT_HEAD(twice);
ATF_TC_BODY(twice, tc)
{
@@ -286,7 +287,9 @@
ATF_CHECK_EQ(r, 0);
ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 42);
- ATF_REQUIRE_ERRNO(ESRCH, pdwait(fdp, NULL, WEXITED, NULL, NULL) < 0);
+ r = pdwait(fdp, &status, WEXITED, NULL, NULL);
+ ATF_CHECK_EQ(r, 0);
+ ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 42);
close(fdp);
}
diff --git a/tests/sys/kern/procdesc.c b/tests/sys/kern/procdesc.c
--- a/tests/sys/kern/procdesc.c
+++ b/tests/sys/kern/procdesc.c
@@ -547,8 +547,10 @@
"pdwait(fd1): %s", strerror(errno));
ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 42);
- /* The second fd should no longer be able to collect. */
- ATF_REQUIRE_ERRNO(ESRCH, pdwait(fd2, &status, WEXITED, NULL, NULL) < 0);
+ /* The second fd should be able to collect as well. */
+ ATF_REQUIRE_MSG(pdwait(fd2, &status, WEXITED, NULL, NULL) == 0,
+ "pdwait(fd2): %s", strerror(errno));
+ ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 42);
ATF_REQUIRE(close(fd1) == 0);
ATF_REQUIRE(close(fd2) == 0);
diff --git a/tests/sys/kern/ptrace_test.c b/tests/sys/kern/ptrace_test.c
--- a/tests/sys/kern/ptrace_test.c
+++ b/tests/sys/kern/ptrace_test.c
@@ -4232,7 +4232,7 @@
pid_t traced, debuger, wpid;
int pd, status;
- traced = pdfork(&pd, 0);
+ traced = pdfork(&pd, PD_NOWAITPID);
ATF_REQUIRE(traced >= 0);
if (traced == 0) {
raise(SIGSTOP);
@@ -4305,12 +4305,11 @@
ATF_REQUIRE(ptrace(PT_CONTINUE, child, (caddr_t)1, 0) != -1);
/*
- * If process was created by pdfork, the return code have to
- * be collected through process descriptor.
+ * If process was created by pdfork but without PD_NOWAITPID,
+ * the return code is available for wait().
*/
wpid = wait(&status);
- REQUIRE_EQ(wpid, -1);
- REQUIRE_EQ(errno, ECHILD);
+ REQUIRE_EQ(wpid, child);
ATF_REQUIRE(close(pd) != -1);
}
diff --git a/tests/sys/kern/reaper.c b/tests/sys/kern/reaper.c
--- a/tests/sys/kern/reaper.c
+++ b/tests/sys/kern/reaper.c
@@ -764,6 +764,7 @@
ATF_REQUIRE_EQ(pid, child);
r = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
ATF_REQUIRE_EQ(r, 0);
+ close(pd);
r = procctl(P_PID, parent, PROC_REAP_STATUS, &st);
ATF_REQUIRE_EQ(r, 0);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Sep 4, 4:08 PM (19 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38201706
Default Alt Text
D58530.id.diff (3 KB)
Attached To
Mode
D58530: tests/sys/kern: adjust tests for new reaping behavior
Attached
Detach File
Event Timeline
Log In to Comment