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 */
22 else if (pid
[i
] > 0) { /* parent process */
26 else { /* child process (pid = 0) */
27 printf("Child[%d] = %d\n", i
, getpid());
29 /* break, or else every child will spawn it's own children */