Update: fixed the logical bug with fork, if fork returns pid of 0 (parent) the code would die too. undef and 0 both evaluates to false. Thanks to borisz to point out below. Zaxo is right too. ;-)my $program = '/bin/ls'; my $num_children = 5; $SIG{CHLD} = 'IGNORE'; for (1..$num_children) { defined ( my $pid = fork ) or die "Can not fork!"; if (!$pid) { # in child process exec $program; } }
In reply to Re: Launching multiple processes
by Roger
in thread Launching multiple processes
by JeffR100
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |