# New Ticket Created by  "brian d foy" 
# Please include the string:  [perl #130781]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=130781 >


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

Reply via email to