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