return Erestartsys function

Source: Internet
Author: User

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}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.