On Mon, 2004-01-12 at 04:18, A. Pagaltzis wrote: 
> IMO it would be much neater not to have to separately localize
> $SIG{ALRM} but to have restoration optionally done by your module
> on request. I believe the clearest way to handle the syntax would
> be a check for context in sig_set_handler() and returning an
> object that auto-restores the signal in question on destruction
> only if the context is not void.
> 
> That way people could write
> 
>     my $restore = sig_set_handler( ... );
> 
> when they want it undone and simply
> 
>     sig_set_handler( ... );
> 
> when they do want the change to persist until explicit change.
> 
> 

I have come to the same conclusion. It has an additional benefit that
you can explicitly reset things by just undeffing the reference to the
returned object if thats what one wanted to do.

If sig_set_action could handle such an object, I would kill two birds
with one stone.  I think I'll head in that direction.

Today I got the code working with perl 5.005 through 5.008.  and I am
building 5.8.2 now so I can test with that.  Interestingly, with
versions of perl earlier than 5.8, could not get the POSIX::sigaction
routine to behave, so I implemented it "under the covers", but just
setting $SIG{name}.  Which got me identical behavior across all three
versions.

This discussion has been most helpful.



Reply via email to