This commit is contained in:
Michael Kerrisk 2008-07-07 04:16:16 +00:00
parent dcb28126b1
commit 72710182cd
1 changed files with 19 additions and 17 deletions

View File

@ -40,7 +40,7 @@
.\" Added section on system call restarting (SA_RESTART) .\" Added section on system call restarting (SA_RESTART)
.\" Added section on stop/cont signals interrupting syscalls. .\" Added section on stop/cont signals interrupting syscalls.
.\" .\"
.TH SIGNAL 7 2008-07-04 "Linux" "Linux Programmer's Manual" .TH SIGNAL 7 2008-07-07 "Linux" "Linux Programmer's Manual"
.SH NAME .SH NAME
signal \- list of available signals signal \- list of available signals
.SH DESCRIPTION .SH DESCRIPTION
@ -481,25 +481,27 @@ write()
.fi .fi
.in .in
.SS Interruption of System Calls and Library Functions by Signal Handlers .SS Interruption of System Calls and Library Functions by Signal Handlers
If a signal handler is invoked while a system call or library function If a signal handler is invoked while a system call or library
call is blocked, then the call may fail with the error function call is blocked, then either:
.IP * 2
the call is automatically restarted after the signal handler returns; or
.IP *
the call fails with the error
.BR EINTR . .BR EINTR .
The details depend on the interface .PP
(in particular, whether the genealogy of the interface is System V or BSD) Which of these two behaviors occurs depends on the interface and
and whether or not the signal handler was established using the whether or not the signal handler was established using the
.BR SA_RESTART .BR SA_RESTART
flag (see flag (see
.BR sigaction (2)). .BR sigaction (2)).
The details vary across Unix systems; The details vary across Unix systems;
below, are the details for Linux. below, are the details for Linux.
For the following interfaces, If a blocked call to one of the following interfaces is interrupted
if the by a signal handler, then the call will be automatically restarted
after the signal handler returns if the
.BR SA_RESTART .BR SA_RESTART
flag was used, flag was used; otherwise the call will fail with the error
then a blocked call will be restarted after being interrupted
by a signal handler;
otherwise the call will fail with the error
.BR EINTR : .BR EINTR :
.\" The following system calls use ERESTARTSYS, .\" The following system calls use ERESTARTSYS,
.\" so that they are restartable .\" so that they are restartable
@ -512,11 +514,11 @@ otherwise the call will fail with the error
and and
.BR ioctl (2) .BR ioctl (2)
calls on "slow" devices. calls on "slow" devices.
A "slow" device is one where the I/O call may block for an indefinite time, A "slow" device is one where the I/O call may block for an
for example, a terminal, pipe, or socket. indefinite time, for example, a terminal, pipe, or socket.
(A disk is not a slow device according to this definition.) (A disk is not a slow device according to this definition.)
If an I/O call on a slow device has already transferred some data by the If an I/O call on a slow device has already transferred some
time it is interrupted by a signal handler, data by the time it is interrupted by a signal handler,
then the call will return a success status then the call will return a success status
(normally, the number of bytes transferred). (normally, the number of bytes transferred).
.IP * .IP *
@ -532,7 +534,7 @@ and
.BR waitpid (2). .BR waitpid (2).
.IP * .IP *
Socket interfaces: Socket interfaces:
.\" If a timeout i(setsockopt()) is in effect on the socket, then these .\" If a timeout (setsockopt()) is in effect on the socket, then these
.\" system calls switch to using EINTR. Consequently, they and are not .\" system calls switch to using EINTR. Consequently, they and are not
.\" automatically restarted, and they show the stop/cont behavior .\" automatically restarted, and they show the stop/cont behavior
.\" described below. (Verified from 2.6.26 source, and by experiment; mtk) .\" described below. (Verified from 2.6.26 source, and by experiment; mtk)