Erestartsys is a part of the API between the driver and the
Signal-handling code in the kernel. It does not reach User-space (provided
Of course that it's used appropriately in the drivers:)
When a driver needs to wait, and get awoken by a signal (as opposed to
What it ' s really waiting for) the driver should in most cases the
System call so the signal handler can is run (like, your push ctrl-c while
Running Somethinig that "s stuck in a" wait for a interrupt). The kernel
Uses the Erestartsys as a "magic" value saying it ' s OK to restart the
System call automagically after the signal handling was done. The actual
Return-code is switched to EINTR if the system call could not being
restarted.
When the process is in the kernel, the signal is run first, and then the kernel program continues to run.
The driver is used as follows: Wait_event_interruptible () causes the process to sleep and, if the process is awakened by a signal, executes the signal processing function and then executes the driver again.
Wait_event_interruptible (Wq,flag);
if (signal_pending (current))
30 {
PRINTK (kern_alert "process%s is waked by signal/n");
Return-erestartsys;
33}
Application tests are as follows, using the clock signal.
8 static void Sig_alrm (int signo)
9 {
printf ("Alrm time is over/n");
11}
if (signal (sigalrm,sig_alrm) = = Sig_err)
17 {
printf ("Initial alrm clock error/n");
19}