Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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?

like image 360
Ganesh Kundapur Avatar asked Sep 03 '10 07:09

Ganesh Kundapur


People also ask

What are some common issues when handling interrupts?

Note the following common interrupt-related issues: A controller interrupt does not necessarily indicate that both the controller and one of its slave devices are ready. For some controllers, an interrupt can indicate that either the controller is ready or one of its devices is ready but not both.

Can a signal handler be interrupted?

Signal handlers can be interrupted by signals, including their own. If a signal is not reset before its handler is called, the handler can interrupt its own execution. A handler that always successfully executes its code despite interrupting itself or being interrupted is async-signal-safe.

What is signal interruption?

An interrupt is a signal emitted by a device attached to a computer or from a program within the computer. It requires the operating system (OS) to stop and figure out what to do next. An interrupt temporarily stops or terminates a service or a current process.


1 Answers

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.

like image 144
shodanex Avatar answered Oct 24 '22 21:10

shodanex