Skip Menu |
Report information
Id: 126037
Status: rejected
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: lue <rnddim [at] gmail.com>
Cc:
AdminCc:

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



Subject: Redirecting standard streams in Proc causes wrong exit code
Download (untitled) / with headers
text/plain 825b
$ perl6 -e 'say ?run("false")' False $ perl6 -e 'say ?run("false", :out)' True $ perl6 -e 'say ?run("false", :err)' True $ perl6 -e 'say ?run("false", :in)' True It appears that specifying any kind of standard stream fails to set the exit code properly ("false" is either a shell built-in or a program otherwise available on linux that does nothing but give a failing exit code). It appears to be down at the VM level, so I don't know if the problem exists on both Moar and JVM. On MoarVM at least, it seems that asking for any of those streams doesn't set up a pointer to the exit-code variable in the struct used to execute a new process. For reference, bash at least still returns the appropriate exit code: $ false </dev/null >/dev/null 2>/dev/null $ echo $? 1 $ perl6 -e 'say run("false", :in, :out, :err).exitcode' 0
Download (untitled) / with headers
text/plain 406b
Thing is that you do not redirect, you capture the streams. So if you capture out, you need to read the output and close it. The return value of close will then tell you the right exit code. This is because when you state that you capture the stream(s), the external program was not started yet. It will start to run when you feed it input and close in, or when you read its output and close that stream.
From: Tobias Leich <email [...] froggs.de>
To: perl6-compiler [...] perl.org
CC: bugs-bitbucket [...] rt.perl.org
Subject: Re: [perl #126037] Redirecting standard streams in Proc causes wrong exit code
Date: Fri, 11 Sep 2015 09:27:37 +0200
Download (untitled) / with headers
text/plain 193b
Thing is that you do not redirect, you capture the streams. So if you capture out, you need to read the output and close it. The return value of close will then tell you the right exit code.


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