From bf30e08ec329479ebc231e3ad8018099f7a0bbb0 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 26 Feb 2012 19:44:14 +0100 Subject: In case fork bombs are going off, use tighter pid calculations. --- level06.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/level06.c b/level06.c index 7e4d9cb..1778f9c 100644 --- a/level06.c +++ b/level06.c @@ -11,17 +11,15 @@ int testfragment(const char *str) { int out[2]; pipe2(out, O_NONBLOCK); - if (fork()) { int status; close(out[1]); - wait(NULL); - while (getpgid(getpid() + 2) == getpid()) + status = wait(NULL); + while (getpgid(status + 1) == getpid()) usleep(100); status = read(out[0], NULL, 1); close(out[0]); return status == 0; - } else { int file; struct rlimit limit; -- cgit v1.2.3-59-g8ed1b