Re: unsafe functions from signal handler



Kasper Dupont wrote:
bill pursell wrote:

I suspect it is because
the address being written to is no longer being read from the variable,
but is already in a register.

I suspect you are right about that.

How do I achieve the desired result?

You can siglongjmp out of the handler.

But if you don't even know, if writing the address is possible,
how can you possibly know what damage could happen by writing to
the address? Sounds like a design mistake.


It's not really a design at all! Just an academic question...I'm
just trying to see how it's done. Is siglongjmp safe to call from
the handler? It's not listed in signal(2) man page.

I'm not sure that this shouldn't start another thread, but it all
ties into the theme of understanding the signal handling
mechanism, so I'll keep it here....

I was having some issues today with the interaction
of signals to a process blocked in wait(). It seems that
wait doesn't behave as described in the man page:
"The wait function suspends execution of the current
process until ... a signal is delivered whose action is to ... call a
signal handling function." But that doesn't seem to be the behavior
I'm seeing. Process A forks and waits for child B. I attach to A via
gdb and see that it's in wait. I send A a SIGTERM. In gdb, I
watch A step into the signal handler, step until the handler returns,
and...find myself still sitting in wait().
Are there issues with wait I need to be aware of?

.



Relevant Pages

  • More trouble with i386 EFLAGS and ptrace
    ... right with signals. ... And this GDB session: ... handler to become pending. ... signal handler (without single-step - good so far). ...
    (Linux-Kernel)
  • Re: Using SetConsoleCtrlHandler
    ... "bare minimum" principal should work even in multithreaded POSIX apps, ... you rely on recursive lock acqusition in your "signal handler" - hard to ... POSIX signals to POSIX processes". ... "Kernel mode APCs interrupt a thread and execute a procedure without ...
    (microsoft.public.win32.programmer.kernel)
  • Re: SetConsoleCtrlHandler
    ... This modified handler does not call ... signals. ... This allows the service to continue running after the user logs ... If the service installs its own console control handler, ...
    (microsoft.public.win32.programmer.kernel)
  • Re: pitfalls of signals
    ... If you have a signal handler that was invoked as a result of your program ... in that case you've invoked undefined behavior ... without invoking undefined behavior ... -Temporarily block a set of signals that includes the one the handler ...
    (comp.lang.c)
  • Re: Mars Rover Controlled By Java
    ... When handling signals Ada provides a higher level abstraction that ... -- Defines the interface for a signal handler ... task Responder is ... interrupt is handled only once. ...
    (comp.programming)