Triggering Default Signal Handler
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Triggering Default Signal Handler




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Triggering Default Signal Handler  
Michael B Allen


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-19-05 10:54 PM

I want to register the same signal handler for all signals that simply
prints information about the signal and then invokes the default behavior
for that signal. I have tried saving the 'oldact' parameter of sigaction
but upon inspection all members appear to be NULL and 0.

Is there a way to invoke the default signal handler for a signal for
which a signal handler has already been registered?

Thanks,
Mike






[ Post a follow-up to this message ]



    Re: Triggering Default Signal Handler  
James Antill


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-19-05 10:54 PM

On Tue, 19 Jul 2005 16:17:27 -0400, Michael B Allen wrote:

> I want to register the same signal handler for all signals that simply
> prints information about the signal and then invokes the default behavior
> for that signal. I have tried saving the 'oldact' parameter of sigaction
> but upon inspection all members appear to be NULL and 0.
>
> Is there a way to invoke the default signal handler for a signal for
> which a signal handler has already been registered?

The only way I know how to do this is...

struct sigaction sa;

if (sigemptyset(&sa.sa_mask) == -1)
err(EXIT_FAILURE, "signal init");

sa.sa_flags   = SA_RESTART;
sa.sa_handler = SIG_DFL;
if (sigaction(s_ig_num, &sa, NULL) == -1)
err(EXIT_FAILURE, "signal("%d")", s_gi_num);

/* log info. */
vlg_sig_info(vlg, "SIG[%d]: %s\n", s_ig_num, strsignal(s_ig_num));
raise(s_ig_num); /* "call default handler" */

...which obviously only works the first time.

--
James Antill -- james@and.org
http://www.and.org/vstr/httpd






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:16 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register