BSD 4_4 release
[unix-history] / usr / src / lib / libc / gen / siginterrupt.3
CommitLineData
74155b62
KB
1.\" Copyright (c) 1985, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
53e9b2ee 3.\"
ad787160
C
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
53e9b2ee 19.\"
ad787160
C
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
ae59e04c 31.\"
ad787160
C
32.\" @(#)siginterrupt.3 8.1 (Berkeley) 6/4/93
33.\"
34.Dd June 4, 1993
ae59e04c
CL
35.Dt SIGINTERRUPT 3
36.Os BSD 4.3
37.Sh NAME
38.Nm siginterrupt
39.Nd allow signals to interrupt system calls
40.Sh SYNOPSIS
41.Fd #include <signal.h>
42.Ft int
43.Fn siginterrupt "int sig" "int flag"
44.Sh DESCRIPTION
45The
46.Fn siginterrupt
47function
53e9b2ee
KM
48is used to change the system call restart
49behavior when a system call is interrupted by the specified signal.
50If the flag is false (0), then system calls will be restarted if
51they are interrupted by the specified signal
52and no data has been transferred yet.
ae59e04c
CL
53System call restart is the default behavior on
54.Bx 4.2 .
55.Pp
56If the flag is true (1),
57then restarting of system calls is disabled.
53e9b2ee
KM
58If a system call is interrupted by the specified signal
59and no data has been transferred,
ae59e04c
CL
60the system call will return \-1 with the global variable
61.Va errno
62set to
63.Dv EINTR .
53e9b2ee
KM
64Interrupted system calls that have started transferring
65data will return the amount of data actually transferred.
ae59e04c
CL
66System call interrupt is the signal behavior found on
67.Bx 4.1
68and
69.At V
70systems.
71.Pp
72Note that the new
73.Bx 4.2
74signal handling semantics are not
53e9b2ee
KM
75altered in any other way.
76Most notably, signal handlers always remain installed until
77explicitly changed by a subsequent
ae59e04c 78.Xr sigaction 2
53e9b2ee 79call, and the signal mask operates as documented in
ae59e04c 80.Xr sigaction 2 .
53e9b2ee
KM
81Programs may switch between restartable and interruptible
82system call operation as often as desired in the execution of a program.
ae59e04c 83.Pp
53e9b2ee 84Issuing a
ae59e04c 85.Fn siginterrupt 3
53e9b2ee
KM
86call during the execution of a signal handler will cause
87the new action to take place on the next signal to be caught.
ae59e04c 88.Sh NOTES
53e9b2ee 89This library routine uses an extension of the
ae59e04c
CL
90.Xr sigaction 2
91system call that is not available in
92.Bx 4.2 ,
53e9b2ee 93hence it should not be used if backward compatibility is needed.
ae59e04c 94.Sh RETURN VALUES
53e9b2ee 95A 0 value indicates that the call succeeded.
ae59e04c
CL
96A \-1 value indicates that an invalid signal number has been supplied.
97.Sh SEE ALSO
98.Xr sigaction 2 ,
99.Xr sigblock 2 ,
100.Xr sigpause 2 ,
101.Xr sigsetmask 2 .
102.Sh HISTORY
103The
104.Fn siginterrupt
105function appeared in
106.Bx 4.3 .