Lines Matching +full:wait +full:- +full:on +full:- +full:read
8 #include <sys/wait.h>
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()
82 // Wait for the child to finish. in CheckChildFinished()
89 ADD_FAILURE() << "Failed to wait for child"; in CheckChildFinished()
106 //------------------------------------------------
110 int pd = -1; in TEST()
118 EXPECT_EQ(-1, pd); in TEST()
132 EXPECT_NE(-1, pd); in TEST()
138 // Tell the child to exit and wait until it is a zombie. in TEST()
145 // Wait for the the child. 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()
207 // Wait for the child to finish. 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()
257 // Wait for the subthread startup using another pipe. in ThreadMain()
305 //------------------------------------------------
310 // when it receives anything on a pipe.
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()
326 …if (verbose) fprintf(stderr, " [%d] child of %d waiting for value on pipe\n", getpid_(), getppid(… in PipePdforkBase()
327 read(pipes[0], &rc, sizeof(rc)); in PipePdforkBase()
328 if (verbose) fprintf(stderr, " [%d] got value %d on pipe, exiting\n", getpid_(), rc); in PipePdforkBase()
380 // Poll again, should have activity on the process descriptor. in TEST_F()
390 // Can multiple processes poll on the same descriptor?
398 // Child: wait for parent to acknowledge startup in TEST_F()
400 // Child: wait for two messages from the parent and the forked process in TEST_F()
402 if (verbose) fprintf(stderr, "[%d] waiting for read 1\n", getpid_()); in TEST_F()
404 if (verbose) fprintf(stderr, "[%d] waiting for read 2\n", getpid_()); in TEST_F()
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()
423 // First, check no activity on the process descriptor yet. in TEST_F()
435 // Now, wait (indefinitely) for activity on the process descriptor. 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()
449 // Parent: wait on process D. in TEST_F()
454 // Also wait on process B. in TEST_F()
472 fprintf(stderr, "For pd %d -> pid %d:\n", pd_, pid_); in TEST_F()
505 EXPECT_OK(read(procfd, buffer, sizeof(buffer))); in TEST_F()
524 pd_ = -1; in TEST_F()
529 EXPECT_EQ(-1, waitpid(pid_, NULL, __WALL)); in TEST_F()
534 EXPECT_EQ(-1, rc); in TEST_F()
550 pd_ = -1; 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()
585 "please pass the -u <uid> flag."; in FORK_TEST()
591 EXPECT_EQ(-1, kill(pid, SIGKILL)); in FORK_TEST()
596 // if it's owned by another user, but this is not implementated on FreeBSD. in FORK_TEST()
598 // On FreeBSD, pdkill() still performs all the same checks that kill() does 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()
708 // Wait for child to start 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()
759 // Wait for grandchild to start. in PdforkParentDeath()
761 EXPECT_EQ(sizeof(grandchild2), (size_t)read(pipefds[0], &grandchild2, sizeof(grandchild2))); in PdforkParentDeath()
769 // Wait for parent to acknowledge the message. in PdforkParentDeath()
777 read(sock_fds[0], &grandchild, sizeof(grandchild)); in PdforkParentDeath()
799 // With PD_DAEMON: child death => closed process descriptor => no effect on grandchild. in TEST()
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()
897 // Return non-zero if we didn't see SIGINT. in FORK_TEST()
928 // Child: wait for shutdown message. No SIGINT handler. The message should in FORK_TEST()
930 if (verbose) fprintf(stderr, "[%d] child about to read()\n", getpid_()); in FORK_TEST()
932 fprintf(stderr, "[%d] child read() returned unexpectedly\n", getpid_()); in FORK_TEST()
935 // Wait for child to start before signalling. in FORK_TEST()
947 //------------------------------------------------
949 // - capability mode
950 // - capabilities
975 int pd = -1; in TEST()
1010 //------------------------------------------------
1037 // Child: wait to receive process descriptor over socket in TEST_F()
1038 …if (verbose) fprintf(stderr, " [%d] child of %d waiting for process descriptor on socket\n", getp… in TEST_F()
1044 EXPECT_EQ(CMSG_LEN(sizeof(int)), cmptr->cmsg_len); in TEST_F()
1047 if (verbose) fprintf(stderr, " [%d] got process descriptor %d on socket\n", getpid_(), pd); in TEST_F()
1050 // Child: confirm we can do pd*() operations on the process descriptor in TEST_F()
1055 // Wait until the parent has closed the process descriptor. in TEST_F()
1066 // Wait until the child has started. 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()
1078 if (verbose) fprintf(stderr, "[%d] send process descriptor %d on socket\n", getpid_(), pd_); in TEST_F()
1081 // Wait until the child has received the process descriptor. in TEST_F()
1088 // wait for child2 in TEST_F()
1091 rc = WIFEXITED(status) ? WEXITSTATUS(status) : -1; in TEST_F()