[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: Signal handler can't be reinstalled after `exec'




> Here is the program sig.pl:
> 
> 	#!/usr/bin/perl
> 	
> 	$| = 1;
> 	
> 	print "Starting.  Pid is $$.\n";
> 	$SIG{HUP} = \&Handler;
> 	for (;;) { sleep 1 }
> 	
> 	sub Handler {
> 	  print "Signal received.\n";
> 	  exec($0);
> 	  die "This should not happen.\n";
> 	}

Roderick Schertler investigated and found that what is going on is
that the signal is blocked inside of Handler to prevent it from being
re-delivered; the sigmask is then retained across the exec() call, so
subsequent HUPs are also blocked.  So it probably doesn't qualify as
an actual bug.  Nevertheless I wondered if there was some way to make
the expected behavior less surprising.  

The obvious answer (`Keep track of the sigmask and if there is an
exec() from a signal handler have Perl automatically restore the
sigmask that was in effect outside the signal handler') sounded like
an extremely special special case, and I did not like it.  But I
thought maybe someone else would have a better idea.


References to:
Mark-Jason Dominus <mjd@plover.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]