mmap not async-signal-safe?
Shachar Shemesh
shachar at shemesh.biz
Thu Jul 18 06:36:57 IDT 2013
Hi all,
As we all know, from a signal handler it is only safe to call functions
that are "async signal safe". I have a couple of questions (three,
actually), if anyone happens to know the answer to:
First, why the name? The list contains functions that are obviously not
async. Does that mean these functions are only safe in non-blocking
mode? (make sense, but you'd expect it to be better documented)
The second is why isn't mmap and munmap on this list? These are
functions that are handled entirely by the kernel, and will, therefor,
never block on something that is up to the program that is currently
halted by the signal. Mmap is, in fact, marked as async-signal-safe on
Solaris[1]. And yet, Posix decided not to include it in its list. On a
related note - is mmap async-signal-safe on Linux?
And, lastly, what is the signal delivery flow in the kernel? What
happens when a signal arrives in the middle of a blocking system call?
Is the signal handler really called before the system call code has
finished? The prospect seems so absurd to me that it defies all logic,
as well as my understanding of the process, but that is the only
explanation I have for why mmap should not be signal handler safe.
Thanks,
Shachar
1- http://docs.oracle.com/cd/E19963-01/html/821-1463/mmap-2.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20130718/75b2c26c/attachment.html>
More information about the Linux-il
mailing list