restart_syscall(2)
β¨ restart_syscall(2) β the System Calls Manual glow-up β¨
okay bestie, welcome to restart_syscall(2), straight out of the Linux System Calls Manual π
this one's a lil niche, a lil internal, and honestly kind of iconic in a "you will literally never call this yourself" way. let's get into it π«Ά
πΈ NAME πΈ
restart_syscall β restart a system call after interruption by a stop signal β¨
π SYNOPSIS π
long restart_syscall(void);
Note: There is no glibc wrapper for this system call; see NOTES. π
π DESCRIPTION π
so. restart_syscall() is the system call that restarts certain system calls after a process got stopped by a signal (think SIGSTOP or SIGTSTP) and then later got resumed by receiving a SIGCONT. and like β this thing is designed only for internal use by the kernel. it's not for us. it's giving backstage pass only π
here's the tea: restart_syscall() is used for restarting only those system calls that, when restarted, should adjust their time-related parameters. the lucky lil list is:
poll(2)(since Linux 2.6.24) πnanosleep(2)(since Linux 2.6) βclock_nanosleep(2)(since Linux 2.6) πfutex(2), when employed with theFUTEX_WAIT(since Linux 2.6.22) andFUTEX_WAIT_BITSET(since Linux 2.6.31) operations π₯
restart_syscall() restarts the interrupted system call with a time argument that is suitably adjusted to account for the time that has already elapsed β and yes, that includes the time where the process was stopped by a signal π
and honestly? without the restart_syscall() mechanism, restarting these system calls would not correctly deduct the already elapsed time when the process continued execution. so it's lowkey carrying the whole timeout math on its back. main character energy fr fr π
β¨ RETURN VALUE β¨
the return value of restart_syscall() is the return value of whatever system call is being restarted. yes, it's wearing someone else's outfit and pulling it off π
π ERRORS π
errno is set as per the errors for whatever system call is being restarted by restart_syscall(). not its own drama, borrowed drama π
π STANDARDS π
Linux. that's it, that's the standard π
π¦ HISTORY π¦
Linux 2.6. vintage, but make it eternal β¨
π NOTES π
- There is no glibc wrapper for this system call, because it is intended for use only by the kernel and should never be called by applications. put the phone down bestie, this one's not for you π
- the kernel uses
restart_syscall()to ensure that when a system call is restarted after a process has been stopped by a signal and then resumed bySIGCONT, then the time that the process spent in the stopped state is counted against the timeout interval specified in the original system call. so it's all accounted for, no cap π«Ά - BUT. in the case of system calls that take a timeout argument and automatically restart after a stop signal plus
SIGCONT, but which do not have therestart_syscall()mechanism built in β then, after the process resumes execution, the time that the process spent in the stop state is not counted against the timeout value. π notable examples of system calls that suffer this problem are:
yeah. those three. the timeout math just quietly forgets a chunk of time existed. not their finest moment π
- from user space, the operation of
restart_syscall()is largely invisible: to the process that made the system call that is restarted, it appears as though that system call executed and returned in the usual fashion. stealth mode: activated π§
π SEE ALSO π
sigaction(2), sigreturn(2), signal(7) β go read these, they're the friend group π
and that's the whole page, bestie!! this gem comes to you from Linux man-pages 6.20, dated 2026-02-08 π slay, stay curious, and please don't call restart_syscall() directly, it's literally not your business π
β¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2013, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms