diff options
Diffstat (limited to 'lib/App/Beam/Command.pm')
-rw-r--r-- | lib/App/Beam/Command.pm | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/App/Beam/Command.pm b/lib/App/Beam/Command.pm index 1b6c343..79b8b06 100644 --- a/lib/App/Beam/Command.pm +++ b/lib/App/Beam/Command.pm @@ -34,13 +34,19 @@ sub run { my $err = gensym; return $self->{status} if exists($self->{status}); - - my $pid = open3(\*STDIN, $out, $err, @{$self->{argv}}); - waitpid($pid, 0); - $self->{status} = $?; - local $/ = undef; - $self->{channel}[CHAN_STDOUT] = <$out>; - $self->{channel}[CHAN_STDERR] = <$err>; + + eval { + my $pid = open3(\*STDIN, $out, $err, @{$self->{argv}}); + waitpid($pid, 0); + }; + if ($@) { + $self->{status} = $@; + } else { + $self->{status} = $?; + local $/ = undef; + $self->{channel}[CHAN_STDOUT] = <$out>; + $self->{channel}[CHAN_STDERR] = <$err>; + } return $self->{status}; } |