-8

From The Linux Programming Interface

a signal is delivered at one of the following times:

  • when the process is rescheduled after it earlier timed out (i.e., at the start of a time slice); or
  • at completion of a system call (delivery of the signal may cause a blocking system call to complete prematurely).

How can I tell if a signal can interrupt the execution of a system call?

What system calls can be interrupted by what signals, in the sense of terminating prematurely?

What system calls are not interruptible by what signals?

Thanks.

  • You have a comprehensive list in the signal(7) manpage of your linux system -- below 'Interruption of system calls and ...". Basically read-like, write-like and wait-like system calls can be interrupted and automatically restarted. The sleep- and poll-like syscalls are interrupted but not restarted, even if the handler was set with SA_RESTART. – mosvy Dec 26 '18 at 8:01
  • Thanks. Either way in your comment, the signals can interrupt the system calls. My question is about whether a signal can interrupt a system call or not. – Tim Dec 26 '18 at 14:16
  • Why don't you read that part of the system(7) man page? It lists all the system calls that can be interrupted, and explains in detail when and how they can be interrupted. The manpage of each system call also mentions under 'ERRORS' if it can set errno to EINTR. I've tried to logically summarize it for you. I don't understand what you mean by "either way": read-, write-, wait-, sleep- and poll-like are not the only kinds of system calls. fork() and _exit() won't be interrupted by a signal, for instance. – mosvy Dec 26 '18 at 16:07
-1

My guess of what mosvy said in comments is that

  • the system calls which can be interrupted by signals are those listed in "Interruption of system calls and ..." sections in the signal(7) manpage, regardless of whether they can be restarted, and

  • the system calls which can't be interrupted by signals are those not listed there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.