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 the FUTEX_WAIT (since Linux 2.6.22) and FUTEX_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 by SIGCONT, 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 the restart_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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms