From bfa901ed0b347ff8542a7936b08872c02373721b Mon Sep 17 00:00:00 2001 From: Guru Prasad Srinivasa Date: Thu, 10 Mar 2016 19:00:31 -0500 Subject: [PATCH] Updated forkbomb so only the parent prints success messages --- userland/testbin/forkbomb/forkbomb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/userland/testbin/forkbomb/forkbomb.c b/userland/testbin/forkbomb/forkbomb.c index f1c919c..ac60fd6 100644 --- a/userland/testbin/forkbomb/forkbomb.c +++ b/userland/testbin/forkbomb/forkbomb.c @@ -64,11 +64,14 @@ main(void) time_t start_time_s, time_now_s; unsigned long start_time_ns, time_now_ns; __time(&start_time_s, &start_time_ns); + int parent_pid = getpid(); while (1) { fork(); __time(&time_now_s, &time_now_ns); - if(time_now_s - start_time_s > TEST_DURATION) { + // Only parent gets to print + if(getpid() == parent_pid && + time_now_s - start_time_s > TEST_DURATION) { success(TEST161_SUCCESS, SECRET, "/testbin/forkbomb"); }