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.