On Wed, Feb 03, 2016 at 01:37:18AM +0200, Peter Pentchev wrote:
> Hi,
> 
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "false"; say 
> $p.exitcode;'                            1
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "false", 
> :out; say $p.exitcode;'
> 0
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "false", 
> :out; print $p.out.slurp-rest; say $p.exitcode;'
> 0
> [roam@straylight ~]$ 
> 
> So, uhm, what am I missing?  Shouldn't $p.exitcode remain 1 no matter whether
> I've invoked run() with or without :out?  Should I file a bug?
> 
> It doesn't matter whether the program actually produces any output on
> the standard output stream:
> 
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "sh", "-c", 
> "env LANG=C date; exit 3"; say $p.exitcode;'                                  
>              
> Wed Feb  3 01:34:50 EET 2016
> 3
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "sh", "-c", 
> "env LANG=C date; exit 3", :out; say "<<<" ~ $p.out.slurp-rest ~ ">>>"; say 
> $p.exitcode;'                                                                 
>        
> <<<Wed Feb  3 01:35:35 EET 2016
> >>>
> 0
> [roam@straylight ~]$

Hm.  Okay.  I think I figured it out.  When I added a $p.out.close
call to make sure that the process has *really* exited, it threw
a X::Proc::Unsuccessful exception at me right there.  For some
reason I thought that assigning the process to a variable would
protect me from the exception.

However, I'm still a bit confused - the Proc documentation seems to
say that exitcode() will return -1, not 0, if the process has not
ended yet.  Is this the real problem here?

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@freebsd.org p...@storpool.com
PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13

Attachment: signature.asc
Description: PGP signature

Reply via email to