perl-ipc-run

How to test the exit status from IPC::Run3

泪湿孤枕 提交于 2019-12-19 11:32:10
问题 I'm trying to test the Perl module IPC::Run3 but having difficulty in checking whether a command is failed or successful. I know that IPC::Run3 issues an exit code if something is wrong with its arguments, but what about if the arguments are ok but the command does not exist? How can I test the following example? Having a subroutine to call Run3 sub runRun3 { my $cmd = shift; my ($stdout, $stderr); run3($cmd, \undef, \$stdout, \$stderr); # if( $? == -1 ) { if (! $stdout and ! $stderr) { die

How to tell when an IPC::Run job has finished

元气小坏坏 提交于 2019-12-06 07:26:25
Is there a simple, reliable way to tell when an IPC::Run task has completed, i.e. any child process(es) have exited? The docs are astonishingly silent on this. It seems that looping on pumpable works, though it's not really documented clearly as the right way to do things: use strict; use warnings; use IPC::Run; use 5.12.0; my $handle = IPC::Run::start(['sleep', '10']); while ($handle->pumpable) { sleep(0.5); # do other stuff in the event loop # so we don't want to block on finish } $handle->finish; print("exited with '" . $handle->result . "'"); Is there a better option? finish blocks, but

How to test the exit status from IPC::Run3

微笑、不失礼 提交于 2019-12-01 13:02:36
I'm trying to test the Perl module IPC::Run3 but having difficulty in checking whether a command is failed or successful. I know that IPC::Run3 issues an exit code if something is wrong with its arguments, but what about if the arguments are ok but the command does not exist? How can I test the following example? Having a subroutine to call Run3 sub runRun3 { my $cmd = shift; my ($stdout, $stderr); run3($cmd, \undef, \$stdout, \$stderr); # if( $? == -1 ) { if (! $stdout and ! $stderr) { die "Something is wrong"; } else { print "OK \n"; } } when command $cmds[0] below is executed (the ls