Lines Matching +full:include +full:- +full:pid
1 // SPDX-License-Identifier: GPL-2.0-or-later
8 * waitpid(pid, WNOHANG) should return 0 if there is a running child
10 * waitpid(pid, WNOHANG) should return the pid of the child if
13 * waitpid(-1, 0) should return -1 with ECHILD if
16 * waitpid(-1, WNOHANG) should return -1 with ECHILD if
21 #include <sys/types.h>
22 #include <signal.h>
23 #include <errno.h>
24 #include <sys/wait.h>
25 #include <stdlib.h>
26 #include "tst_test.h"
28 static void cleanup_pid(pid_t pid) in cleanup_pid() argument
30 if (pid > 0) { in cleanup_pid()
31 kill(pid, SIGKILL); in cleanup_pid()
32 waitpid(pid, NULL, 0); in cleanup_pid()
38 pid_t pid, ret; in case0() local
41 pid = SAFE_FORK(); in case0()
42 if (pid == 0) { in case0()
49 ret = waitpid(pid, &status, WNOHANG); in case0()
51 if ((ret == -1) && (errno == EINTR)) in case0()
59 cleanup_pid(pid); in case0()
64 SAFE_WAITPID(pid, NULL, 0); in case0()
66 tst_res(TPASS, "waitpid(pid, WNOHANG) = 0 for a running child"); in case0()
71 pid_t pid, ret; in case1() local
74 pid = SAFE_FORK(); in case1()
75 if (pid == 0) in case1()
79 ret = waitpid(pid, &status, WNOHANG); in case1()
81 if ((ret == -1) && (errno == EINTR)) in case1()
86 if (ret == pid) in case1()
90 ret, pid); in case1()
91 cleanup_pid(pid); in case1()
106 tst_res(TPASS, "waitpid(pid, WNOHANG) = pid for an exited child"); in case1()
114 ret = waitpid(-1, &status, 0); in case2()
116 if (ret != -1) { in case2()
117 tst_res(TFAIL, "Expected -1, got %d", ret); in case2()
126 tst_res(TPASS, "waitpid(-1, 0) = -1 with ECHILD if no children"); in case2()
134 ret = waitpid(-1, &status, WNOHANG); in case3()
135 if (ret != -1) { in case3()
136 tst_res(TFAIL, "WNOHANG: Expected -1, got %d", ret); in case3()
145 tst_res(TPASS, "waitpid(-1, WNOHANG) = -1 with ECHILD if no children"); in case3()