2 gcc fork_mult.c -o fork_mult -Wall -W -Wextra -ansi -pedantic */
13 pid_t pid
[NUM_CHILDS
];
16 for (i
= 0; i
< NUM_CHILDS
; i
++) {
17 if ((pid
[i
] = fork()) < 0) { /* fork error */
21 else if (pid
[i
] > 0) { /* parent process */
24 else if (pid
[i
] == 0) { /* child process */
25 printf("Child[%d] = %d\n", i
, getpid());
27 /* break, or else every child will spawn it's own children */