When a program forks the fork returns the pid of the child so the parent can use this to kill it at will.
my $pid = fork();
if ( $pid == 0 ) {
# child process so do stuff here
# usually have an exit to ensure child
# does not escape this if clause
exit;
}
else {
# parent process, waits a while
sleep 60
# kills child
kill 9, $pid;
}
# parent continues on here (as will child if not killed or exited)
You seem somewhat confused about forking. The parent is the whole program. It spawns children and continues. The child is a whole copy of the program and gets copies of all the data/handles to that point.
There is a vast quantity of discussion about fork on PM - you can find it using Super Search
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|