My understanding is that, in general, the behavior is undefined if you call a non-async signal safe function from a signal handler, but I’ve heard that linux allows you to call any system call safely. Is this true? Also, the only portable behavior for a SIGSEGV handler is to abort or exit, but I understand linux will actually resume execution if you return, true?
Share
I would believe that any real system call can be called from a signal handler. A true syscall has a number in
<asm/unistd.h>(or<asm/unistd_64.h>).some posix functions from section 2 of man pages are implemented thru a “multiplexing” syscall, so they are not “true syscalls” in my sense
A system call is an atomic operation from the point of view of the application; it is almost like a single machine instruction (from inside the application). See this answer.
If your question is: can a
SIGSEGVhandler change the faulty address mapping thrumprotectormmap? then I believe the answer is yes (at least on x86-64 & x86-32 architectures), as said here in a question you quoted, but I did not try. I’ve read that doing that is quite inefficient (SIGSEGVhandling is not very fast, andmprotectormmapis also a bit slow). In particular, mimicking this way Hurd/Mach external pagers might be inefficient.