Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Redirecting standard streams in Proc causes wrong exit code #4531
$ perl6 -e 'say ?run("false")'
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
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.
It will start to run when you feed it input and close in, or when you read its output and close that stream.