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 HVIn reply to SIG{INT} not handling CTRL-C ??? by girishatreya2005
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |