Changed forkbomb to only print one success message

This commit is contained in:
Scott Haseley 2016-03-11 14:56:01 -05:00
parent bfa901ed0b
commit 922370ebd4
2 changed files with 4 additions and 8 deletions

View File

@ -21,13 +21,6 @@ templates:
- name: /testbin/forkbomb
timesout: yes
timeout: 15.0
output:
- text: "/testbin/forkbomb: SUCCESS"
- text: "/testbin/forkbomb: SUCCESS"
- text: "/testbin/forkbomb: SUCCESS"
- text: "/testbin/forkbomb: SUCCESS"
- text: "/testbin/forkbomb: SUCCESS"
- name: kmalloc
output:
- text: "kmalloc: out of memory"

View File

@ -65,13 +65,16 @@ main(void)
unsigned long start_time_ns, time_now_ns;
__time(&start_time_s, &start_time_ns);
int parent_pid = getpid();
int did_print = 0;
while (1) {
fork();
__time(&time_now_s, &time_now_ns);
// Only parent gets to print
if(getpid() == parent_pid &&
time_now_s - start_time_s > TEST_DURATION) {
time_now_s - start_time_s > TEST_DURATION &&
!did_print) {
did_print = 1;
success(TEST161_SUCCESS, SECRET, "/testbin/forkbomb");
}