A
AdamKaye-Smith
Hello ,
I am trying to run a shell process from perl program and giving it a
time limit to run in.
To do this I use the perl function - alarm to set of a timer and when my
program gets the %SIG{ALRM} signal it initiates a kill which is sent to
all processes in the group ie kill 1 ,(-$$). This all works as expected.
The problem is that this also kills my main perl program.
I attempt to make the main perl program ignore the kill signal by doing
the following :
local $SIG{HUP} = 'IGNORE';
but when I do this the child process also ignores the kill signal
here is the test program:
#!/usr/bin/perl -w
$SIG{HUP} = 'DEFAULT';
eval {
local $SIG{HUP} = 'IGNORE';
local $SIG{ALRM} = sub { kill 1 , (-$$) ; print "got rid of
them\n"; };
alarm 6;
system ("sleep 30 ");
alarm 0;
};
$SIG{HUP} = 'DEFAULT';
print "going from here\n";
How can I get this program to time out the system called process,
without timing out the main perl program.
I am running this under Fedora Core 4 op sys.
At my wits end,
Adam
I am trying to run a shell process from perl program and giving it a
time limit to run in.
To do this I use the perl function - alarm to set of a timer and when my
program gets the %SIG{ALRM} signal it initiates a kill which is sent to
all processes in the group ie kill 1 ,(-$$). This all works as expected.
The problem is that this also kills my main perl program.
I attempt to make the main perl program ignore the kill signal by doing
the following :
local $SIG{HUP} = 'IGNORE';
but when I do this the child process also ignores the kill signal
here is the test program:
#!/usr/bin/perl -w
$SIG{HUP} = 'DEFAULT';
eval {
local $SIG{HUP} = 'IGNORE';
local $SIG{ALRM} = sub { kill 1 , (-$$) ; print "got rid of
them\n"; };
alarm 6;
system ("sleep 30 ");
alarm 0;
};
$SIG{HUP} = 'DEFAULT';
print "going from here\n";
How can I get this program to time out the system called process,
without timing out the main perl program.
I am running this under Fedora Core 4 op sys.
At my wits end,
Adam