http://www.perlmonks.org?node_id=849012

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

Hi wise ones, I've defined a routine in my script to handle the SIGINT signal .
main(); sub main () { $SIG{'INT'} = 'exit_handler'; for ( my $count = 1 ; $count <= 3 ; $count ++ ) { child_fork(); } } sub exit_handler () { print " I caught CTRL-C \n"; ### Do cleanup . kill the children $SIG{'INT'} = 'DEFAULT'; exit; } sub child_fork() { my $child_pid ; $child_pid = fork(); if( $child_pid > 0) { print "returning to parent\n"; }else { my $count = 0 ; while ($count <= 60) { print "In child now "; sleep 1; $count=$count+1; } print "returning to parent now \n"; exit; } }

I fork some children from the parent. And when the children are running , I send the SIGINT signal to the parent by pressing CTRL-C on the terminal. But the parent is not handling the SIGINT signal.

If no children are forked, the parent catches the SIGINT signal without any issues and exits.

Any pointers on what I am missing will be really helpful .

Thanks, Girish HV