ioctl_tty.2: Remove duplicated text
[man-pages.git] / man2 / restart_syscall.2
blob4de6bb12da5f567f7298c0b2aef8a49c0a3d6458
1 .\" Copyright (c) 2013 by Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" http://thread.gmane.org/gmane.linux.kernel/76552/focus=76803
26 .\" From: Linus Torvalds <torvalds <at> transmeta.com>
27 .\" Subject: Re: [PATCH] compatibility syscall layer (lets try again)
28 .\" Newsgroups: gmane.linux.kernel
29 .\" Date: 2002-12-05 02:51:12 GMT
30 .\"
31 .\" See also Section 11.3.3 of Understanding the Linux Kernel, 3rd edition
32 .\"
33 .TH RESTART_SYSCALL 2 2021-03-22 "Linux" "Linux Programmer's Manual"
34 .SH NAME
35 restart_syscall \- restart a system call after interruption by a stop signal
36 .SH SYNOPSIS
37 .nf
38 .B long restart_syscall(void);
39 .fi
40 .PP
41 .IR Note :
42 There is no glibc wrapper for this system call; see NOTES.
43 .SH DESCRIPTION
44 The
45 .BR restart_syscall ()
46 system call is used to restart certain system calls
47 after a process that was stopped by a signal (e.g.,
48 .BR SIGSTOP
50 .BR SIGTSTP )
51 is later resumed after receiving a
52 .BR SIGCONT
53 signal.
54 This system call is designed only for internal use by the kernel.
55 .PP
56 .BR restart_syscall ()
57 is used for restarting only those system calls that,
58 when restarted, should adjust their time-related parameters\(emnamely
59 .BR poll (2)
60 (since Linux 2.6.24),
61 .BR nanosleep (2)
62 (since Linux 2.6),
63 .BR clock_nanosleep (2)
64 (since Linux 2.6),
65 and
66 .BR futex (2),
67 when employed with the
68 .BR FUTEX_WAIT
69 (since Linux 2.6.22)
70 and
71 .BR FUTEX_WAIT_BITSET
72 (since Linux 2.6.31)
73 operations.
74 .\" These system calls correspond to the special internal errno value
75 .\" ERESTART_RESTARTBLOCK. Each of the system calls has a "restart"
76 .\" helper function that is invoked by restart_syscall().
77 .\" Notable (as at Linux 3.17) is that poll() has such a "restart"
78 .\" function, but ppoll(), select(), and pselect() do not.
79 .\" This means that the latter system calls do not take account of the
80 .\" time spent in the stopped state when restarting.
81 .BR restart_syscall ()
82 restarts the interrupted system call with a
83 time argument that is suitably adjusted to account for the
84 time that has already elapsed (including the time where the process
85 was stopped by a signal).
86 Without the
87 .BR restart_syscall ()
88 mechanism, restarting these system calls would not correctly deduct the
89 already elapsed time when the process continued execution.
90 .SH RETURN VALUE
91 The return value of
92 .BR restart_syscall ()
93 is the return value of whatever system call is being restarted.
94 .SH ERRORS
95 .I errno
96 is set as per the errors for whatever system call is being restarted by
97 .BR restart_syscall ().
98 .SH VERSIONS
99 The
100 .BR restart_syscall ()
101 system call is present since Linux 2.6.
102 .SH CONFORMING TO
103 This system call is Linux-specific.
104 .SH NOTES
105 There is no glibc wrapper for this system call,
106 because it is intended for use only by the kernel and
107 should never be called by applications.
109 The kernel uses
110 .BR restart_syscall ()
111 to ensure that when a system call is restarted
112 after a process has been stopped by a signal and then resumed by
113 .BR SIGCONT ,
114 then the time that the process spent in the stopped state is counted
115 against the timeout interval specified in the original system call.
116 In the case of system calls that take a timeout argument and
117 automatically restart after a stop signal plus
118 .BR SIGCONT ,
119 but which do not have the
120 .BR restart_syscall ()
121 mechanism built in, then, after the process resumes execution,
122 the time that the process spent in the stop state is
123 .I not
124 counted against the timeout value.
125 Notable examples of system calls that suffer this problem are
126 .BR ppoll (2),
127 .BR select (2),
129 .BR pselect (2).
131 From user space, the operation of
132 .BR restart_syscall ()
133 is largely invisible:
134 to the process that made the system call that is restarted,
135 it appears as though that system call executed and
136 returned in the usual fashion.
137 .SH SEE ALSO
138 .BR sigaction (2),
139 .BR sigreturn (2),
140 .BR signal (7)
141 .\" FIXME . ppoll(2), select(2), and pselect(2)
142 .\"     should probably get the restart_syscall() treatment:
143 .\"     If a select() call is suspended by stop-sig+SIGCONT, the time
144 .\"     spent suspended is *not* deducted when the select() is restarted.
145 .\" FIXME . check whether recvmmsg() handles stop-sig+SIGCONT properly.