xref: /aosp_15_r20/external/ltp/testcases/kernel/controllers/cgroup/cgroup_regression_fork_processes.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2009 FUJITSU LIMITED
4  *
5  * Author: Li Zefan <[email protected]>
6  */
7 
8 #include <sys/types.h>
9 #include <sys/wait.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12 
main(void)13 int main(void)
14 {
15 	int i;
16 	pid_t pid;
17 
18 	while (1) {
19 		for (i = 0; i < 200; i++) {
20 			pid = fork();
21 			if (pid == 0) {
22 				exit(0);
23 			} else if (pid == -1) {
24 				continue;
25 			}
26 		}
27 
28 		for (i = 0; i < 200; i++)
29 			if (wait(NULL) < 0)
30 				break;
31 	}
32 
33 	return 0;
34 }
35