It is currently Sun, 17 Nov 2019 13:18:49 GMT



 
Author Message
 siglongjmp not async-signal-safe?
According to the SUS v3, there are only 116 async-signal-safe functions that
are safe to call from a signal handler that may have interrupted an unsafe
function. Alas, siglongjmp and longjmp are not on the list. So, which shall
I conclude:

1. The SUS is mistaken.
2. They are not safe and should not be used for that reason.
3. The whole issue of async-signal-safety is besides the point when you're
long-jumping. (If this is true, I believe #1 is also true, as the SUS
doesn't discuss this possibility.)

--Marc



 Sun, 09 Oct 2005 03:43:51 GMT   
 siglongjmp not async-signal-safe?
In article <MpydnTzPYaZnBzijXTW...@speakeasy.net>,

How could the system possibly ensure that longjmp is safe to call?
For example, suppose that free() is mucking with the free-list when
the signal comes in, and the free-list is in an inconsistent state.
If you longjmp back to main, you'd never be able to safely call
malloc afterwards.

Therefore, I think that 2. is the case.

-andy



 Sun, 09 Oct 2005 05:34:06 GMT   
 siglongjmp not async-signal-safe?
On 22 Apr 2003 21:34:06 GMT, a...@pirx.lan (Andy Isaacson) wrote:

I would also weigh in for point 2.  Calling any non-reentrant function
after performing a non-local "goto" from a signal handler is
semantically equivalent to calling that function from the handler.
Thus siglongjmp() and longjmp() are not in the SUSv3 list.

Cheers

Michael



 Sun, 09 Oct 2005 11:36:35 GMT   
 siglongjmp not async-signal-safe?

 Marc> According to the SUS v3, there are only 116 async-signal-safe
 Marc> functions that are safe to call from a signal handler that may
 Marc> have interrupted an unsafe function. Alas, siglongjmp and
 Marc> longjmp are not on the list. So, which shall I conclude:

 Marc> 1. The SUS is mistaken.
 Marc> 2. They are not safe and should not be used for that reason.
 Marc> 3. The whole issue of async-signal-safety is besides the point
 Marc> when you're long-jumping. (If this is true, I believe #1 is
 Marc> also true, as the SUS doesn't discuss this possibility.)

see the "APPLICATION USAGE" section for sigaction() where this is
specifically addressed.

If you longjmp (via either longjmp or siglongjmp) out of a signal
handler that has interrupted an async-signal-unsafe function, then for
the remainder of the program's execution, the results of calling any
async-signal-unsafe function is undefined.

You can safely longjmp out of a signal handler (or call any other
unsafe function for that matter) only if you know that the signal did
not interrupt an unsafe function (usually the only way to know this is
to keep the signal blocked except in regions known to be safe).

--
Andrew.

comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>



 Mon, 10 Oct 2005 13:12:02 GMT   
 
   [ 4 post ] 

Similar Threads

1. Why is localtime_r() not ASYNC-SIGNAL-safe ?

2. poll/select not async-signal safe

3. Delivery of signals when thread not async safe

4. What is async-signal safe function

5. To async or not not async

6. Thread-safe and Signal-safe

7. mmap, thread-safe, and signal-safe

8. siglongjmp and signal-unsafe functions

9. Solaris 8 threads: If a routine is Async-Signal-Safe is it also thread Safe?


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software