aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2012-02-26 19:44:14 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2012-02-26 19:44:56 +0100
commitbf30e08ec329479ebc231e3ad8018099f7a0bbb0 (patch)
tree142c0f264a0d6b7b83984800fd4d5445788496ef
parentAesthetics. (diff)
downloadStripe-CTF-bf30e08ec329479ebc231e3ad8018099f7a0bbb0.tar.xz
Stripe-CTF-bf30e08ec329479ebc231e3ad8018099f7a0bbb0.zip
In case fork bombs are going off, use tighter pid calculations.
-rw-r--r--level06.c6
1 files 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;