Issue with signal handling, interrupt handling
While the process is executing a blocking system call, say read or write, signal has arrived. Does the system call is terminated with the error EINTR? Does the system call is restarted after handling the system call?
Suppose, system call is terminated with the error EINTR, Kernel handles the开发者_如何学JAVA signal before returing to user space.
Does the signal handle is executed in user mode/kernel mode? If its in user mode, does there'll be return to the instruction after the system call(read/write) during which signal arrived or again it goes to kernel mode after handling the signal and returns to the user from ret_from_syscall. How the execution is resumed at the instruction next to the system call during which signal arrived?
Is it possible to restart the system by passing SA_RESTART flag in sigaction?
Signal is executed in user mode, but with a different user context, then return to kernel, which return to user_mode with ret_from_syscall. The behaviour of system call when signal handler are installed with SA_RESTART depends on the system call.
A description of which system call are restarted is available in recent version of the signal overview manpage :
man 7 signal
If the SA_RESTART flag is not used, system call is not restarted.
精彩评论