As others have already pointed out, you need to explicitly call exit in the portion that will be executed by the child processes. In other words, try something a bit more like this:
#!/usr/bin/env perl use strict; use warnings; my @a = (1,2,3); for my $i (@a) { my $pid = fork(); if ( $pid == 0 ) { print "$i -> i am a forked child\n"; exit; } else { print "$i -> forking $pid\n"; } } while((wait()) > 0) {};
See perlfork and perlipc for more examples.
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: fork child process
by jeffa
in thread fork child process
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |