OSDN Git Service

9a68f02b2a6c39e40ae2a077caea90c8d5841ee8
[linuxjm/LDP_man-pages.git] / original / man2 / restart_syscall.2
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 2014-02-11 "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 .B int restart_syscall(void);
38
39 .IR Note :
40 There is no glibc wrapper for this system call; see NOTES.
41 .SH DESCRIPTION
42 The
43 .BR restart_syscall ()
44 system call is used to restart certain system calls
45 after a process that was stopped by a signal (e.g.,
46 .BR SIGSTOP
47 or
48 .BR SIGTSTP )
49 is later resumed after receiving a
50 .BR SIGCONT
51 signal.
52 This system call is designed only for internal use by the kernel.
53
54 .BR restart_syscall ()
55 is used for restarting only those system calls that,
56 when restarted, should adjust their time-related parameters\(emnamely
57 .BR poll (2)
58 (since Linux 2.6.24),
59 .BR nanosleep (2)
60 (since Linux 2.6),
61 .BR clock_nanosleep (2)
62 (since Linux 2.6),
63 and
64 .BR futex (2),
65 when employed with the
66 .BR FUTEX_WAIT
67 (since Linux 2.6.22)
68 and
69 .BR FUTEX_WAIT_BITSET
70 (since Linux 2.6.31)
71 operations.
72 .\" These system calls correspond to the special internal errno value
73 .\" ERESTART_RESTARTBLOCK. Each of the system calls has a "restart"
74 .\" helper function that is invoked by restart_syscall().
75 .BR restart_syscall ()
76 restarts the interrupted system call with a
77 time argument that is suitably adjusted to account for the
78 time that has already elapsed (including the time where the process
79 was stopped by a signal).
80 Without the
81 .BR restart_syscall ()
82 mechanism, restarting these system calls would not correctly deduce the
83 already elapsed time when the process continued execution.
84 .SH RETURN VALUE
85 The return value of
86 .BR restart_syscall ()
87 is the return value of whatever system call is being restarted.
88 .SH ERRORS
89 .I errno
90 is set as per the errors for whatever system call is being restarted by
91 .BR restart_syscall ().
92 .SH VERSIONS
93 The
94 .BR restart_syscall ()
95 system call is present since Linux 2.6.
96 .SH CONFORMING TO
97 This system call is Linux-specific.
98 .SH NOTES
99 There is no glibc wrapper for this system call,
100 because it is intended for use only by the kernel and
101 should never be called by applications.
102
103 From user space, the operation of
104 .BR restart_syscall (2)
105 is largely invisible:
106 to the process that made the system call that is restarted,
107 it appears as though that system call executed and
108 returned in the usual fashion.
109 .\"
110 .\" FIXME
111 .\" There is one oddness in the implementation though, with respect to
112 .\" nanosleep() (and probably also clock_nanosleep()). The scenario
113 .\" is as follows:
114 .\"    1. Start a nanosleep() for (say) 30 seconds,
115 .\"    2. Stop the process with (say) SIGTSTP (^Z).
116 .\"    3. Resume the process with SIGCONT,
117 .\"    4. Upon return, the 'rem' argument of nanosleep() will contain the
118 .\"       remaining unslept time **at the time when SIGTSTP was delivered**.
119 .\" The behavior at point 4 is odd, but doesn't violate the standards, which
120 .\" specify the treatment of 'rem' only when the system call returns with
121 .\" the error EINTR (i.e., the call was interrupted by a signal handler).
122 .\"
123 .SH SEE ALSO
124 .BR sigaction (2),
125 .BR sigreturn (2),
126 .BR signal (7)
127 .\" FIXME select(2) should probably get the restart_syscall() treatment:
128 .\"     If a select() call is suspended by stop-sig+SIGCONT, the time
129 .\"     spent suspended is *not* deducted when the select() is restarted.
130 .\" FIXME: check whether recvmmsg() handles stop-sig+SIGCONT properly.
131 .SH COLOPHON
132 This page is part of release 3.67 of the Linux
133 .I man-pages
134 project.
135 A description of the project,
136 information about reporting bugs,
137 and the latest version of this page,
138 can be found at
139 \%http://www.kernel.org/doc/man\-pages/.