# New Ticket Created by  Aleks-Daniel Jakimenko-Aleksejev 
# Please include the string:  [perl #131764]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=131764 >


Code:

sub get-output() {
    my $proc = Proc::Async.new: :w, ‘head’, ‘-n’, ‘1’;
    my $success;
    react {
        whenever $proc.stdout { $success = True }
        whenever $proc.start  { die ‘FAIL!’ unless $success }

        $proc.print: “one\ntwo\nthree\nfour”;
        $proc.close-stdin;
    }
    say $++;
}

loop { get-output }


Again, the result depends on your luck. Ideally it should not “die” ever, 
because there should always be one line in the output and therefore $success 
will be set to true. However, sometimes its stdout is empty and therefore it 
fails. It may fail after 20+ executions, and sometimes  it fails almost 
immediately.

Related ticket: https://rt.perl.org/Ticket/Display.html?id=131763

Reply via email to