Re: Q: Signal processing

Richard B. Johnson (root@chaos.analogic.com)
Sat, 7 Aug 1999 20:53:16 -0400 (EDT)


On Sat, 7 Aug 1999, [iso-8859-1] Jörg Pleumann wrote:
[SNIPPED]
>
> * Is it necessary to return from a signal handler to the system, or is
> it okay if control stays in my application?
>

You can stay in your application, but further signals are blocked until
you unblock them (check POSIX signals for details). If you do longjump()
stuff from your signal handler, you might (read will) have problems with
local variables, i.e., stuff on the stack.

> * If control has to return to the kernel, is there a way to influence
> what happens in the application *after* the signal handler has been
> left?

Sure:

int sig_caugth;

void sig_handler(int sig)
{
sig_caught = sig;
}

prog()
{
sig_caugth = NOTHING;
.....; /* set up signal handler */
.....;
pause(); /* Wait for a signal */
/* Control returns here soon after your sig_hangler() returns */

switch(sig_caught)
{
.....;
}
}

Cheers,
Dick Johnson
**** FILE SYSTEM WAS MODIFIED ****
Penguin : Linux version 2.2.6 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/