in reply to Timeout and kill
$pid = fork;
Congratulations, now you have two processes. And they both will execute the next block:
eval { alarm $timeout; $result = `$solver $file`; waitpid($pid, 0); };
So now you have two solver programs.
The standard idiom for forking goes something like this:
my $pid = fork(); die "failed to fork" unless defined $pid; if ($pid) { # we are parent. do things } else { # we are child. do other things }
You probably want to put your eval block into the child portion. However -- this still won't work, as the child cannot return the $result variable to the parent -- they don't share memory. Returning a value will require some ipc trickery.
But the trickery is not worth it. Just listen to the other poster and don't fork. It'll work fine.
|
|---|