in reply to Need Function for Timing out shell commands
Problem is i need the exit code from the shell command, so i can't change the code to fork/exec
There is no such limitation when using fork/exec. The waitpid built-in lets you retrieve the exit status of the child.
update: if you want to get the output from the program, you would like to launch the process using open:
And then use a select loop to read from $fh while checking that it does not time out or otherwise send a signal to the process.my $pid = open my $fh, '-|', @cmd or die "open failed $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need Function for Timing out shell commands
by Anonymous Monk on Sep 15, 2011 at 16:55 UTC | |
by salva (Canon) on Sep 16, 2011 at 06:28 UTC |