Page MenuHomeFreeBSD

D58546.id183080.diff
No OneTemporary

D58546.id183080.diff

Index: sys/kern/procdesc.c
===================================================================
--- sys/kern/procdesc.c
+++ sys/kern/procdesc.c
@@ -523,16 +523,29 @@
ATF_TC_BODY(pdopenpid_pdwait_only_one, tc)
{
pid_t child;
- int fd1, fd2, status;
+ int fd1, fd2, pip[2], status;
+
+ ATF_REQUIRE_EQ(pipe(pip), 0);
child = pdfork(&fd1, PD_DAEMON);
ATF_REQUIRE_MSG(child >= 0, "pdfork: %s", strerror(errno));
- if (child == 0)
- _exit(42);
+ if (child == 0) {
+ char c;
+ close(pip[1]);
+ /* Block until the parent has opened the second fd. */
+ (void)read(pip[0], &c, 1);
+ _exit(42);
+ }
+ ATF_REQUIRE(close(pip[0]) == 0);
+
+ /* Open the second fd while the child is still alive. */
fd2 = pdopenpid(child, 0);
ATF_REQUIRE_MSG(fd2 >= 0, "pdopenpid: %s", strerror(errno));
+ /* Release the child so that it exits. */
+ ATF_REQUIRE(close(pip[1]) == 0);
+
/* Collect via the first fd. */
ATF_REQUIRE_MSG(pdwait(fd1, &status, WEXITED, NULL, NULL) == 0,
"pdwait(fd1): %s", strerror(errno));

File Metadata

Mime Type
text/plain
Expires
Sat, Aug 8, 4:19 AM (6 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36209530
Default Alt Text
D58546.id183080.diff (1019 B)

Event Timeline