Updated forkbomb so only the parent prints success messages
This commit is contained in:
		@@ -64,11 +64,14 @@ main(void)
 | 
				
			|||||||
	time_t start_time_s, time_now_s;
 | 
						time_t start_time_s, time_now_s;
 | 
				
			||||||
	unsigned long start_time_ns, time_now_ns;
 | 
						unsigned long start_time_ns, time_now_ns;
 | 
				
			||||||
	__time(&start_time_s, &start_time_ns);
 | 
						__time(&start_time_s, &start_time_ns);
 | 
				
			||||||
 | 
						int parent_pid = getpid();
 | 
				
			||||||
	while (1) {
 | 
						while (1) {
 | 
				
			||||||
		fork();
 | 
							fork();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		__time(&time_now_s, &time_now_ns);
 | 
							__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");
 | 
								success(TEST161_SUCCESS, SECRET, "/testbin/forkbomb");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user