Unix Programming - Triggering Default Signal Handler

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > July 2005 > Triggering Default Signal Handler





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Triggering Default Signal Handler
Michael B Allen

2005-07-19, 5: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

James Antill

2005-07-19, 5: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

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com