Interrupted system call error (eintr) occurs when semop waits for signals in Linux)

Source: Internet
Author: User

Error Description: (semop function call, strerror (errno) output result)

Interrupted system call

Platform: RedHat Linux

 

The description of eintr in Linux is as follows:

While blocked in this system call, the process caught a signal.

The UNIX document [IEEE Std 1003.1-2008] describes eintr as follows:

The semop () function was interrupted by a signal.

 

If these two statements are literally understood, the intr signal appears during the semop wait process.

However, the error should be solved. The cause of the error is generally caused by the code written by the programmer.

After debugging and output, locate the cause of the problem and finally find all the problems:

When semop is waiting for resources, if a thread in the process uses system to call the shell function at this time, semop returns immediately and the error code is eintr. The error message is as follows. Don't look at this small problem. In my system, due to the use of various means to implement IPC (intra-process communication ), the reason is that a system call is not that simple.

 

[The solution to this problem on the network is not found yet, so I hope to help others.]

 

I searched some posts on Google, and one of my friends once said: Due to deadlock

Because semaphores themselves prevent deadlocks. I made a special experiment and used a mutex variable, a semaphore, and two semaphores in different order to achieve deadlocks. However, the system did not show the expected "interrupted system call ", but simply waiting.

 

Today, when I read "UNIX Network Programming 1st-volume interface API", I saw this sentence and understood why this error occurs. The original Article is as follows:

"The basic rule for slow system calls is: when a process blocked by a slow System Call captures a signal and the corresponding signal processing function returns, the system call may return an eintr error. Some kernels Automatically Restart some interrupted system calls ."

Here, the slow System Call (slow System Call) refers to a function that causes blocking like accept, and the semop function discussed above should also be like this, so when the current eintr signal occurs, the system call is interrupted and an error is returned. The error code is eintr. Then, we can restart our system call from this error number.

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.