It sounds as if you've got the basics already (though it's hard to tell).
my $pid = fork(); die "Can't fork: $!" if ! defined $pid; if ( $pid ) { # parent $SIG{INT} = sub { warn "Sending sig INT to child PID $pid"; kill 'INT' => $pid; }; wait; } else { # child $SIG{INT} = sub { die "Caught sig INT" }; sleep 1 while 1; exit; }
Note that without the signal handler in the child, it will still die when it gets the INT signal. I put it in the example just to make the signal visible.
In reply to Re: How to terminate a childprocess by press Ctrl_c
by kyle
in thread How to terminate a childprocess by press Ctrl_c
by LH2007
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |