Change forkbomb to print progress

This commit is contained in:
Scott Haseley 2016-04-07 13:17:23 -04:00
parent 1600e40d22
commit a56bf008ba

View File

@ -66,16 +66,22 @@ main(void)
__time(&start_time_s, &start_time_ns); __time(&start_time_s, &start_time_ns);
int parent_pid = getpid(); int parent_pid = getpid();
int did_print = 0; int did_print = 0;
int iters = 0;
while (1) { while (1) {
fork(); fork();
__time(&time_now_s, &time_now_ns);
// Only parent gets to print // Only parent gets to print
if(getpid() == parent_pid && if(getpid() == parent_pid) {
time_now_s - start_time_s > TEST_DURATION && TEST161_LPROGRESS(0);
!did_print) { if (iters > 0 && iters % 20 == 0) {
did_print = 1; putchar('\n');
success(TEST161_SUCCESS, SECRET, "/testbin/forkbomb"); }
iters++;
__time(&time_now_s, &time_now_ns);
if (time_now_s - start_time_s > TEST_DURATION && !did_print) {
did_print = 1;
success(TEST161_SUCCESS, SECRET, "/testbin/forkbomb");
}
} }
pid = getpid(); pid = getpid();