sub system { my $pid = fork; if (!$pid) { exec @_; exit(-1); } while (1) { if (waitpid($pid, \$?, 0) > 0) { # supposing this calls the C waitpid! return $? } if ($! == EINTR) { run_signal_handlers(); next; } return -1; } }