W
Weirong Zhu
I have a perl script, the main body of which is a for loop. In each
iteration the script use "system" to call outside exe to do some work.
The whole script may run very long time. Sometimes, I want to use
Ctrl+C to terminate the script. However, when I use ctrl+c, I can only
terminate the child process invoked by system, the script itself is
still running. Then I have to open another term to kill the script by
its pid.
Then I try to use sigtrap to catch the ctrl+c (SIGINT).
use sigtrap qw(handler mysig_handler normal-signals);
sub mysig_handler{
my($sig) = @_;
print "Caught a SIG$sig--shutting down\n";
die "Terminated by user: $!\n";
}
however, when I use ctrl+c, I still only kill the child process
invoked by system, the scripts still continue running.
Is there any solutions?
Thanks very much!
Regards,
Weirong
iteration the script use "system" to call outside exe to do some work.
The whole script may run very long time. Sometimes, I want to use
Ctrl+C to terminate the script. However, when I use ctrl+c, I can only
terminate the child process invoked by system, the script itself is
still running. Then I have to open another term to kill the script by
its pid.
Then I try to use sigtrap to catch the ctrl+c (SIGINT).
use sigtrap qw(handler mysig_handler normal-signals);
sub mysig_handler{
my($sig) = @_;
print "Caught a SIG$sig--shutting down\n";
die "Terminated by user: $!\n";
}
however, when I use ctrl+c, I still only kill the child process
invoked by system, the scripts still continue running.
Is there any solutions?
Thanks very much!
Regards,
Weirong