| 1 |
/* { dg-require-stack-size "1004*4+2*8" } */ |
| 2 |
|
| 3 |
int pid_count = 0; |
| 4 |
|
| 5 |
unsigned int getopt (int, const char**, const char*); |
| 6 |
unsigned long long atoll (const char*); |
| 7 |
int fork (void); |
| 8 |
void kill (int, int); |
| 9 |
|
| 10 |
int |
| 11 |
main (int argc, const char *argv[]) |
| 12 |
{ |
| 13 |
unsigned int c; |
| 14 |
unsigned long long maxbytes = 0; |
| 15 |
extern const char *optarg; |
| 16 |
int i; |
| 17 |
int pid_cntr; |
| 18 |
int pid; |
| 19 |
int pid_list[1000]; |
| 20 |
while ((c = getopt (argc, argv, "c:b:p:wvh")) != (-1)) |
| 21 |
{ |
| 22 |
switch ((char) c) |
| 23 |
{ |
| 24 |
case 'b': |
| 25 |
maxbytes = atoll (optarg); |
| 26 |
} |
| 27 |
} |
| 28 |
pid = fork (); |
| 29 |
while ((pid != 0) && (maxbytes > 1024 * 1024 * 1024)) |
| 30 |
{ |
| 31 |
maxbytes = maxbytes - (1024 * 1024 * 1024); |
| 32 |
pid = fork (); |
| 33 |
if (pid != 0) |
| 34 |
pid_cntr++; |
| 35 |
pid_list[i] = pid; |
| 36 |
} |
| 37 |
while ((pid_count < pid_cntr)) |
| 38 |
{ |
| 39 |
} |
| 40 |
kill (pid_list[i], 9); |
| 41 |
} |