Lines Matching +full:closed +full:- +full:loop
21 #include "capsicum-test.h"
30 //------------------------------------------------
38 pid_t pid = -1; in pdwait4_()
49 fprintf(f, " User CPU time=%ld.%06ld\n", (long)ru->ru_utime.tv_sec, (long)ru->ru_utime.tv_usec); in print_rusage()
50 …fprintf(f, " System CPU time=%ld.%06ld\n", (long)ru->ru_stime.tv_sec, (long)ru->ru_stime.tv_usec); in print_rusage()
51 fprintf(f, " Max RSS=%ld\n", ru->ru_maxrss); in print_rusage()
62 (long)stat->st_dev, (long)stat->st_ino, stat->st_mode, in print_stat()
63 (long)stat->st_nlink, stat->st_uid, stat->st_gid, in print_stat()
64 (long)stat->st_rdev, (long)stat->st_size, (long)stat->st_blksize, in print_stat()
65 (long)stat->st_blocks, in print_stat()
67 (long)stat->st_birthtime, in print_stat()
69 (long)stat->st_atime, (long)stat->st_mtime, (long)stat->st_ctime); in print_stat()
106 //------------------------------------------------
110 int pd = -1; in TEST()
118 EXPECT_EQ(-1, pd); in TEST()
132 EXPECT_NE(-1, pd); in TEST()
159 EXPECT_EQ(-1, pdwait4_(pd, &status, 0, &ru)); in TEST()
166 int pd = -1; in TEST()
171 EXPECT_EQ(-1, pid); in TEST()
178 EXPECT_NE(-1, now); in TEST()
181 int pd = -1; in TEST()
186 EXPECT_EQ(-1, pdgetpid(pd, &pid)); in TEST()
202 EXPECT_LT((now - stat.st_atime), 2); in TEST()
208 pid_t pd_pid = -1; in TEST()
215 int pd = -1; in TEST()
228 // pd*() operations should fail on a non-process descriptor. in TEST()
229 EXPECT_EQ(-1, pdkill(fd, SIGUSR1)); in TEST()
231 EXPECT_EQ(-1, pdwait4_(fd, &status, 0, NULL)); in TEST()
233 EXPECT_EQ(-1, pdgetpid(fd, &pid)); in TEST()
255 // Child: start a subthread then loop. in ThreadMain()
305 //------------------------------------------------
313 PipePdforkBase(int pdfork_flags) : pd_(-1), pid_(-1) { in PipePdforkBase()
323 // Child process: blocking-read an int from the pipe then exit with that value. in PipePdforkBase()
418 // |--pid B: pdfork()ed process, blocked on read() in TEST_F()
419 // |--pid C: fork()ed process, in read() above in TEST_F()
420 // +--pid D: doppel process, here in TEST_F()
437 // - pid C will finish its two read() calls, write to the pipe and exit. in TEST_F()
438 // - pid B will unblock from read(), and exit in TEST_F()
439 // - this will generate an event on the process descriptor... in TEST_F()
440 // - ...in both process A and process D. in TEST_F()
472 fprintf(stderr, "For pd %d -> pid %d:\n", pd_, pid_); in TEST_F()
524 pd_ = -1; in TEST_F()
529 EXPECT_EQ(-1, waitpid(pid_, NULL, __WALL)); in TEST_F()
532 // Having closed the process descriptor means that pdwait4(pd) now doesn't work. in TEST_F()
534 EXPECT_EQ(-1, rc); in TEST_F()
545 // Child should only die when last process descriptor is closed. in TEST_F()
550 pd_ = -1; in TEST_F()
556 // Can no longer pdwait4() the closed process descriptor... in TEST_F()
557 EXPECT_EQ(-1, pdwait4_(pd_, &status, WNOHANG, NULL)); in TEST_F()
559 // ...but can pdwait4() the still-open process descriptor. in TEST_F()
578 // Child process: loop forever. in FORK_TEST()
585 "please pass the -u <uid> flag."; in FORK_TEST()
591 EXPECT_EQ(-1, kill(pid, SIGKILL)); in FORK_TEST()
643 EXPECT_EQ(-1, waitpid(pid_, &status, __WALL)); in TEST_F()
650 pd_ = -1; in TEST_F()
670 // pdkill() on zombie is no-op. in TestPdkill()
675 // pdkill() on reaped process gives -ESRCH. in TestPdkill()
677 EXPECT_EQ(-1, pdkill(pd, SIGINT)); in TestPdkill()
690 int pd = -1; in TEST()
696 // Child: tell the parent that we have started before entering the loop, in TEST()
714 EXPECT_EQ(-1, pdkill(pd, 0xFFFF)); in TEST()
734 // +--pid B: fork()ed process, starts a child process with pdfork() then in PdforkParentDeath()
736 // +--pid C: pdfork()ed process, looping forever in PdforkParentDeath()
793 // By default: child death => closed process descriptor => grandchild death. in TEST()
799 // With PD_DAEMON: child death => closed process descriptor => no effect on grandchild. in TEST()
820 // all been closed should generate SIGCHLD. The child process needs
829 EXPECT_EQ(-1, waitpid(pid_, NULL, __WALL)); in TEST_F()
864 // Wildcard waitpid(-1) should not see the pdfork()ed child because in TEST_F()
867 EXPECT_EQ(-1, waitpid(-1, &rc, WNOHANG)); in TEST_F()
871 pd_ = -1; in TEST_F()
890 // Note: we could receive the SIGINT just before sleep(), so we use a loop in FORK_TEST()
897 // Return non-zero if we didn't see SIGINT. in FORK_TEST()
947 //------------------------------------------------
949 // - capability mode
950 // - capabilities
975 int pd = -1; in TEST()
979 // Child: loop forever. in TEST()
1010 //------------------------------------------------
1044 EXPECT_EQ(CMSG_LEN(sizeof(int)), cmptr->cmsg_len); in TEST_F()
1055 // Wait until the parent has closed the process descriptor. in TEST_F()
1061 // Last process descriptor closed, expect death in TEST_F()
1069 // Send the process descriptor over the pipe to the sub-process in TEST_F()
1072 cmptr->cmsg_level = SOL_SOCKET; in TEST_F()
1073 cmptr->cmsg_type = SCM_RIGHTS; in TEST_F()
1074 cmptr->cmsg_len = CMSG_LEN(sizeof(int)); in TEST_F()
1091 rc = WIFEXITED(status) ? WEXITSTATUS(status) : -1; in TEST_F()