If a signal is caught during the system calls listed below, the call may be forced to terminate with the error EINTR, the call may return with a data transfer shorter than requested, or the call may be restarted. Restart of pending calls is requested by setting the SA_RESTART bit in sa_flags. The affected system calls include open(2), read(2), write(2), sendto(2), recvfrom(2), sendmsg(2) and recvmsg(2) on a communications channel or a slow device (such as a terminal, but not a regular file) and during a wait(2) or ioctl(2). However, calls that have already committed are not restarted, but instead return a partial success (for example, a short read count).
NOTE
The sa_mask field specified in act is not allowed to block SIGKILL or SIGSTOP. Any attempt to do so will be silently ignored. The following functions are either reentrant or not interruptible by signals and are async-signal safe. Therefore applications may invoke them, without restriction, from signal-catching functions:
Base Interfaces:
_exit, access, alarm, cfgetispeed, cfgetospeed, cfsetispeed, cfsetospeed, chdir, chmod, chown, close, creat, dup, dup2, execle, execve, fcntl, fork, fpathconf, fstat, fsync, getegid, geteuid, getgid, getgroups, getpgrp, getpid, getppid, getuid, kill, link, lseek, mkdir, mkfifo, open, pathconf, pause, pipe, raise, read, rename, rmdir, setgid, setpgid, setsid, setuid, sigaction, sigaddset, sigdelset, sigemptyset, sigfillset, sigismember, signal, sigpending, sigprocmask, sigsuspend, sleep, stat, sysconf, tcdrain, tcflow, tcflush, tcgetattr, tcgetpgrp, tcsendbreak, tcsetattr, tcsetpgrp, time, times, umask, uname, unlink, utime, wait, waitpid, write.
Realtime Interfaces:
aio_error, clock_gettime, sigpause, timer_getoverrun, aio_return, fdatasync, sigqueue, timer_gettime, aio_suspend, sem_post, sigset, timer_settime.
ANSI C Interfaces:
strcpy, strcat, strncpy, strncat, and perhaps some others.
Extension Interfaces:
strlcpy, strlcat.
All functions not in the above lists are considered to be unsafe with respect to signals. That is to say, the behaviour of such functions when called from a signal handler is undefined. In general though, signal handlers should do little more than set a flag; most other actions are not safe.
Also, it is good practice to make a copy of the global variable errno and restore it before returning from the signal handler. This protects against the side effect of errno being set by functions called from inside the signal handler.
RETURN VALUES
.Rv -std sigaction
EXAMPLES
There are three possible prototypes the handler may match: