[comp.unix.wizards] calling default signal routines

kak@stc-auts.UUCP (Kris Kugel) (01/13/88)

I'd like to call the default signal handlers in my code's signal
handler after fixing up my terminal state.  Is there anyway of
calling the default signal handlers?  Is there a way of doing
what the default handlers do another way?
(stop: stop the process, and dump_core: dump core and die)

	Kris A. Kugel
	Storage Tek:    ...{ uunet!nbires, hao, ihnp4 }!stcvax!stc-auts!kak

chris@mimsy.UUCP (Chris Torek) (01/19/88)

In article <239@stc-auts.UUCP>, kak@stc-auts.UUCP (Kris Kugel) writes:
>I'd like to call the default signal handlers in my code's signal
>handler after fixing up my terminal state.  Is there anyway of
>calling the default signal handlers? ...
>(stop: stop the process, and dump_core: dump core and die)

Easy:

	catch_sig(sig)
		int sig;
	{

		clean_up();
		(void) signal(sig, SIG_DFL);
		(void) kill(getpid(), sig);
		/* if we got here, it must have been benign */
		/* (e.g., stop followed by continue, or SIGCHLD/SIGCLD) */
	}
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

gwyn@brl-smoke.ARPA (Doug Gwyn ) (01/20/88)

In article <239@stc-auts.UUCP> kak@stc-auts.UUCP (Kris Kugel) writes:
>I'd like to call the default signal handlers in my code's signal
>handler after fixing up my terminal state.  Is there anyway of
>calling the default signal handlers?  Is there a way of doing
>what the default handlers do another way?

I assume you mean you want to obtain the SIG_DFL actions after
your handler has done its bit.  Try

	signal( signal_number, SIG_DFL );
	kill( getpid(), signal_number );

matt@oddjob.UChicago.EDU (Mr. nEtural) (01/20/88)

) In article <239@stc-auts.UUCP>, kak@stc-auts.UUCP (Kris Kugel) writes:
) >I'd like to call the default signal handlers in my code's signal
) >handler after fixing up my terminal state.  ...

In article <10240@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
) 	catch_sig(sig)
) 		int sig;
) 	{
) 		clean_up();
) 		(void) signal(sig, SIG_DFL);
) 		(void) kill(getpid(), sig);
) 		/* if we got here, it must have been benign */
) 		/* (e.g., stop followed by continue, or SIGCHLD/SIGCLD) */
) 	}

Don't forget to unmask the current signal, otherwise the explicitly
sent signal won't be delivered until some slightly later time.

				Matt Crawford

gp@picuxa.UUCP (Greg Pasquariello X1190) (01/21/88)

In article <239@stc-auts.UUCP>, kak@stc-auts.UUCP writes:
> I'd like to call the default signal handlers in my code's signal
> handler after fixing up my terminal state.  Is there anyway of
> calling the default signal handlers?  Is there a way of doing
> what the default handlers do another way?
> (stop: stop the process, and dump_core: dump core and die)
> 
> 	Kris A. Kugel
> 	Storage Tek:    ...{ uunet!nbires, hao, ihnp4 }!stcvax!stc-auts!kak


(I'm talking SYS5, I know nothing about BDS )

When your code's signal handler is called, the signal number is passed to
it and (except for SIGILL SIGTRAP, and one other (SIGPWR?)) the signal
catching function is reset to the default.  Therefore, within your signal
trap, just generate the same signal when you wish, and the default signal
handler will be executed.  For example:

void 	sighandler()
	.
	.
	.

void sighandler(i)
int	i
	{
	/* do your thing here */
	kill(getpid(),i);
	}

Greg Pasquariello
picuxa!Tinman!gp