summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbcook <>2014-07-09 14:32:24 +0000
committerbcook <>2014-07-09 14:32:24 +0000
commit5d9826b5df86f270974b004a7ed021cfb02f6879 (patch)
tree3d2f52d62a811f5e39d9bc569ebf02f349351721
parentfc64ddc4b0d85b533bef98d8851464f470c2cb39 (diff)
downloadopenbsd-5d9826b5df86f270974b004a7ed021cfb02f6879.tar.gz
openbsd-5d9826b5df86f270974b004a7ed021cfb02f6879.tar.bz2
openbsd-5d9826b5df86f270974b004a7ed021cfb02f6879.zip
check for EINTR when calling waitpid.
ok jsing@
-rw-r--r--src/regress/lib/libc/arc4random-fork/arc4random-fork.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/regress/lib/libc/arc4random-fork/arc4random-fork.c b/src/regress/lib/libc/arc4random-fork/arc4random-fork.c
index 35a9ea6a98..af617af625 100644
--- a/src/regress/lib/libc/arc4random-fork/arc4random-fork.c
+++ b/src/regress/lib/libc/arc4random-fork/arc4random-fork.c
@@ -18,6 +18,7 @@
18#include <sys/wait.h> 18#include <sys/wait.h>
19#include <assert.h> 19#include <assert.h>
20#include <err.h> 20#include <err.h>
21#include <errno.h>
21#include <stdlib.h> 22#include <stdlib.h>
22#include <string.h> 23#include <string.h>
23#include <unistd.h> 24#include <unistd.h>
@@ -71,6 +72,16 @@ usage()
71 errx(1, "usage: %s [-bp]", __progname); 72 errx(1, "usage: %s [-bp]", __progname);
72} 73}
73 74
75static pid_t
76_waitpid(pid_t pid, int *stat_loc, int options)
77{
78 pid_t ret;
79 do {
80 ret = waitpid(pid, stat_loc, options);
81 } while (ret == -1 && errno == EINTR);
82 return ret;
83}
84
74int 85int
75main(int argc, char *argv[]) 86main(int argc, char *argv[])
76{ 87{
@@ -123,11 +134,11 @@ main(int argc, char *argv[])
123 134
124 fillbuf(bufparent); 135 fillbuf(bufparent);
125 136
126 CHECK_EQ(pidone, waitpid(pidone, &status, 0)); 137 CHECK_EQ(pidone, _waitpid(pidone, &status, 0));
127 CHECK(WIFEXITED(status)); 138 CHECK(WIFEXITED(status));
128 CHECK_EQ(0, WEXITSTATUS(status)); 139 CHECK_EQ(0, WEXITSTATUS(status));
129 140
130 CHECK_EQ(pidtwo, waitpid(pidtwo, &status, 0)); 141 CHECK_EQ(pidtwo, _waitpid(pidtwo, &status, 0));
131 CHECK(WIFEXITED(status)); 142 CHECK(WIFEXITED(status));
132 CHECK_EQ(0, WEXITSTATUS(status)); 143 CHECK_EQ(0, WEXITSTATUS(status));
133 144