I was testing some code using Sys V Semaphores for its ability to recover from various events, and for one such test, I deleted the semaphore set (from the terminal) while the process was in its critical section. When it came time to release the lock with another call to semop
, it returned an error code with errno
set to EIDRM
.
According to the manpage for semop, these are the descriptions of what each errno
means:
EIDRM: The semaphore set was removed.
EINVAL: The semaphore set doesn't exist, or semid is less than zero, or nsops has a nonpositive value.
What I want to understand is the difference between a semaphore set that doesn't exist, and one that has been removed. I had thought that the difference was that errno
would be set to EINVAL
if the Semaphore set had been removed prior to the system call, and EIDRM
if the Semaphore set had existed at the start of the System call and been removed before completion (such as the Semaphore set being deleted while the process is blocked on the Semaphore through the system call).