I am trying to catch a timeout exception with IPC::Run on Windows 10 (using Strawberry Perl version 5.30.1):
use strict;
use warnings;
use feature qw(say);
use Data::Dumper;
use IPC::Run qw(run timeout);
my $timeout = 3;
my $cmd = ['perl', '-E', "sleep 5; say 'stdout_text'; say STDERR 'stderr_text'"];
my $in;
my $out;
my $err;
my $result;
eval {
$result = run $cmd, $in, $out, $err, timeout($timeout );
};
if ( $@ ) {
say "Timed out: $@";
}
else {
print Dumper({ out => $out, err => $err});
}
The above program dies after 3 seconds with:
Terminating on signal SIGBREAK(21)
How can I catch the timeout exception in the Perl script?
See also this issue.
question from:https://stackoverflow.com/questions/65894141/how-to-catch-timeout-exception-with-ipcrun-on-windows-10