in reply to How to terminate a childprocess by press Ctrl_c

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.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.