...and $? is zero, so I can't get a return code.
close waits for the subprocess and sets $?:
my $pid = open X, '-|', 'echo foo; exit 42' or die $!; my $out = <X>; my $ok = close X; print STDERR "out=$out"; printf STDERR "\$?=%s\n", $? >> 8 unless $ok; __END__ out=foo $?=42
See close for details.
In reply to Re: Execute command, show realtime output and get exit code
by Eliya
in thread Execute command, show realtime output and get exit code
by afunix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |