# New Ticket Created by  Alex Jakimenko 
# Please include the string:  [perl #126561]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=126561 >


First of all, let's look at the code that works:
my $p = run 'bash', '-c', 'exit 5';
say $p.exitcode;

Result:
5

Correct!

OK, now let's say I want to have the output as well:
my $p = run 'bash', '-c', 'exit 5', :out;
say 'Out: "' ~ $p.out.slurp-rest ~ '"';
say $p.exitcode;

Result:
Out: ""
0

But the exitcode is clearly not 0.

It turns out that you have to close .out in order to get it to work:
my $p = run 'bash', '-c', 'exit 5', :out;
$p.out.close;
say $p.exitcode;


I think that it's fine if the exitcode is -1 until it is closed, yet I
don't understand why it does not close it automatically when I do
slurp-rest (perhaps it should?).

Reply via email to