Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > signal not being caught when re-exec()d

Reply
Thread Tools

signal not being caught when re-exec()d

 
 
Jeff 'japhy' Pinyan
Guest
Posts: n/a
 
      06-08-2004
Here is a very simple demonstration of my problem:

#!/usr/bin/perl

BEGIN {
my @args = ($^X, $0, @ARGV);
warn "$$: [@args]\n";
$SIG{USR1} = sub {
warn "$$: re-exec()ing with [@args]\n";
exec @args;
};
}

while (1) { }

I call that code 'exec.pl', and run it thus:

% perl exec.pl arg &

and I get

1234: [/usr/bin/perl exec.pl arg]

Then I send it a USR1 signal (numerical value is 10):

% kill -10 1234

and I get

1234: re-exec()ing with [/usr/bin/perl exec.pl arg]
1234: [/usr/bin/perl exec.pl arg]

Then I try to send it the signal again... and nothing. No messages at
all. But the program is running, with the same PID... I'm baffled.

--
Jeff Pinyan RPI Acacia Brother #734 RPI Acacia Corp Secretary
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)

 
Reply With Quote
 
 
 
 
Jeff 'japhy' Pinyan
Guest
Posts: n/a
 
      06-09-2004
On 8 Jun 2004, Michal Wojciechowski wrote:

>When the signal handler is triggered, the signal that caused it to run
>gets blocked. The new program called with exec inherits the signal
>mask, and therefore blocks the USR1 signal. To be able to catch it
>again, you need to reset the signal mask. Use the POSIX sigprocmask
>function:
>
> use POSIX qw(:signal_h);
>
> $sigset = POSIX::SigSet->new;
> sigprocmask(SIG_SETMASK, $sigset);


Ah ha. Thanks very much.

--
Jeff Pinyan RPI Acacia Brother #734 RPI Acacia Corp Secretary
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assignment to output signal from internal signal not istantaneous dibacco73 VHDL 1 02-12-2009 11:28 PM
"Target of signal assignment is not a signal" Nicolas Moreau VHDL 9 07-25-2007 04:21 PM
Need help with python one liners which will not be caught by signal.alarm vj Python 0 04-19-2006 08:52 PM
ItemDataBound not being caught =?Utf-8?B?Sm9u?= ASP .Net 3 04-13-2006 05:26 AM
Response.Redirect gens ThreadAbortException that's either not being caught or thrown a second time. Eric ASP .Net 1 08-19-2005 06:00 PM



Advertisments