Re: run() not capturing exitcode properly?

2017-05-30 Thread Marcel Timmerman

Hi

Exit code is set after closing one of the output channels. If you close 
both,  the errorcode is reset to 0 again. (This might be a bug though)


my $p = run "ls", "dadsad", :out, :err;
say $p.err.lines;
---> (ls: cannot access 'dadsad': No such file or directory)

$p.out.close;
$p.exitcode;
---> 2


Marcel Timmerman


Re: run() not capturing exitcode properly?

2017-05-29 Thread Gabor Szabo
On Tue, May 30, 2017 at 7:21 AM, Gabor Szabo  wrote:
>> my $p = run "ls", "dadsad", :out, :err;
> Proc.new(in => IO::Pipe, out => IO::Pipe.new(:path(""),:chomp), err =>
> IO::Pipe.new(:path(""),:chomp), exitcode => 0, signal => 0, command =>
> ["ls", "dadsad", "adadsa"])
>>
>> $p.exitcode
> 0
>
>
> While for the same command in the shell   $? will hold 1 as the
> directory does not exist.
>
> Is this a bug or am I misunderstanding something?
>
> This is Rakudo version 2017.04.3 built on MoarVM version 2017.04-53-g66c6dda
> implementing Perl 6.c.
>
> Running on OSX.
>
> Gabor

On the other hand if I try to access the captured output or error, an
exception is raised:

> $p.out.slurp: :close;
The spawned command 'ls' exited unsuccessfully (exit code: 1)
  in block  at  line 1\