setcontext in a signal handler

Will Newton will.newton@linaro.org
Tue Mar 4 08:33:00 GMT 2014


On 4 March 2014 16:23, Andreas Schwab <schwab@suse.de> wrote:
> Will Newton <will.newton@linaro.org> writes:
>
>> It's not clear to me that there is any standard that mandates that
>> setcontext cannot be called from a signal handler or whether it is an
>> implementation detail of glibc. Does anybody know of any historical
>> reasons for this being the case?
>
> No function is async-signal-safe unless explicitly described as such.

But is there a reason that setcontext is not safe to call from a
signal handler? It is not obvious to me that there is but I am far
from an expert in this type of analysis.

The Open Group document[1] contains the following wording:

"Signal handlers should use siglongjmp() or setcontext() instead."

[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/setcontext.html

-- 
Will Newton
Toolchain Working Group, Linaro



More information about the Libc-alpha mailing list