git.samba.org
/
tridge
/
junkcode.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
added -C option to enable running on more than 1 node
[tridge/junkcode.git]
/
forklots.c
1
#include <stdio.h>
2
#include <sys/types.h>
3
#include <unistd.h>
4
5
int main(int argc, char *argv[])
6
{
7
int i, n = atoi(argv[1]);
8
pid_t *pids = malloc(n * sizeof(pid_t));
9
10
for (i=0;i<n;i++) {
11
pids[i] = fork();
12
if (pids[i] == 0) {
13
sleep(1000);
14
exit(0);
15
}
16
}
17
18
19
for (i=0;i<n;i++) {
20
waitpid(pids[i], NULL, 0);
21
}
22
return 0;
23
}