Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: send ctrl+c to open3?

by zentara (Archbishop)
on Jul 18, 2014 at 09:12 UTC ( [id://1094187]=note: print w/replies, xml ) Need Help??


in reply to send ctrl+c to open3?

I'm not sure about the CNTRL-C being the best or easiest way to stop the process being run by open3. IPC::Open3 returns a PID, so what you might want to try is intercept the CNTRL-C in the parent, then use Proc::Killfam to killfam 9, $pid;

The killfam is used to get all shells and children related to the $pid in question. Often, the $pid returned by open3, is just a shell used to run your actual program.

Here is how to grab cntrl-c in your main.

# intercept CNTRL-C , kill open3, exit $SIG{INT} = sub { killfam 9,$pid; exit(0) };
You can google for many examples of using Proc::Killfam, I won't repeat them here.

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1094187]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-04-23 13:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found