Skip Menu |
Report information
Id: 130781
Status: new
Priority: 0/
Queue: perl6

Owner: cpan [at] zoffix.com
Requestors: comdog <brian.d.foy [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



From: brian d foy <brian.d.foy [...] gmail.com>
Subject: Using both :out and :err in run() reports the wrong exit code
To: rakudobug [...] perl.org
Date: Tue, 14 Feb 2017 00:25:49 -0500
Download (untitled) / with headers
text/plain 2.6k
Here's a program that starts another program with run() with various combinations of :out and :err. When :out and :err are both specified, the exit code is incorrect. This is 2017.01: #!/Applications/Rakudo/bin/perl6 use v6; my $filename = 'null-program.p6'; my $fh = open $filename, :w; END { unlink $filename } $fh.put( q:to/HERE/ ); #!{ $*EXECUTABLE } $*ERR.say( Q/This goes to standard error/ ); $*OUT.say( Q/This goes to standard output/ ); exit 137; HERE { my $proc = run $*EXECUTABLE, $filename; say "1. Exit is { $proc.exitcode }"; } { my $proc = run $*EXECUTABLE, $filename, :out; $proc.out.slurp-rest( :close ); say "2. Exit is { $proc.exitcode }"; } { my $proc = run $*EXECUTABLE, $filename, :err; $proc.err.slurp-rest( :close ); say "3. EHere's a program that starts another program with run() with various combinations of :out and :err. When :out and :err are both specified, the exit code is incorrect: #!/Applications/Rakudo/bin/perl6 use v6; my $filename = 'null-program.p6'; my $fh = open $filename, :w; END { unlink $filename } $fh.put( q:to/HERE/ ); #!{ $*EXECUTABLE } $*ERR.say( Q/This goes to standard error/ ); $*OUT.say( Q/This goes to standard output/ ); exit 137; HERE { my $proc = run $*EXECUTABLE, $filename; say "1. Exit is { $proc.exitcode }"; } { my $proc = run $*EXECUTABLE, $filename, :out; $proc.out.slurp-rest( :close ); say "2. Exit is { $proc.exitcode }"; } { my $proc = run $*EXECUTABLE, $filename, :err; $proc.err.slurp-rest( :close ); say "3. Exit is { $proc.exitcode }"; } { my $proc = run $*EXECUTABLE, $filename, :out, :err; $proc.out.slurp-rest( :close ); $proc.err.slurp-rest( :close ); say "4. Exit is { $proc.exitcode }"; } The fourth situation reports a different exit code: This goes to standard error This goes to standard output 1. Exit is 137 This goes to standard error 2. Exit is 137 This goes to standard output 3. Exit is 137 4. Exit is 0xit is { $proc.exitcode }"; } { my $proc = run $*EXECUTABLE, $filename, :out, :err; $proc.out.slurp-rest( :close ); $proc.err.slurp-rest( :close ); say "4. Exit is { $proc.exitcode }"; } The fourth situation reports a different exit code: This goes to standard error This goes to standard output 1. Exit is 137 This goes to standard error 2. Exit is 137 This goes to standard output 3. Exit is 137 4. Exit is 0


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org