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; } }