Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Perl 6 Sending input to Proc::Async

by ctilmes (Vicar)
on Feb 01, 2017 at 02:05 UTC ( #1180733=perlquestion: print w/replies, xml ) Need Help??

ctilmes has asked for the wisdom of the Perl Monks concerning the following question:

What is the right way to recognize a bad executable when creating a Proc::Async?

And why, when I try to send the bad executable input does my CATCH not seem to catch the error?
try { my $proc = Proc::Async.new('bad-executable', :w); my $done = $proc.start; say "try sending to bad executable"; await $proc.say("hi there"); say "worked"; $proc.close-stdin; await $done; CATCH { default { say "caught"; } } } say "done";
Running:
$ perl6 -v This is Rakudo version 2017.01 built on MoarVM version 2017.01 implementing Perl 6.c. $ perl6 testit.pl try sending to bad executable $

Replies are listed 'Best First'.
Re: Perl 6 Sending input to Proc::Async
by BrowserUk (Pope) on Feb 01, 2017 at 06:47 UTC

    I suspect you should be doing something like this:

    Note: If you wish to await the Promise and discard its result, using
    try await $p.start;
    will throw if the program exited with non-zero status, as the Proc returned as the result of the Promise throws when sunk and in this case it will get sunk outside the try.

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
    In the absence of evidence, opinion is indistinguishable from prejudice.

      I want it to throw an exception, that's my goal -- to discover that the executable is bad. I have the whole thing wrapped in try{}.

      My problem is that it doesn't throw an exception, rather the whole program exits.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1180733]
Approved by beech
Front-paged by beech
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2021-09-24 16:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?