question about sigtrap!

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,244
Latest member
cryptotaxsoftware12

Latest Threads

Top