Reputation: 267
I was checking the semop()
function and the flag value of structure sembuf
could be either SEM_UNDO or IPC_NOWAIT. So in the case that we pass flag value as 0 then what will be the behavior? Somewhere I read it was a no operation. What does that mean? Can anyone explain?
Upvotes: 1
Views: 1839
Reputation: 753475
The best thing to do is to read the specification — the POSIX specification for semop()
explains it all.
If the flag is 0, it means that the operation may cause the process to hang waiting for the semaphore to become available (if the flag included IPC_NOWAIT
, it would not hang), and it also means that the semaphore value will not be adjusted to undo the operation if the process crashes (if the flag included SEM_UNDO
, the system would record the information necessary to undo the semaphore operation.
Whether that's considered safe or not is up to you.
Upvotes: 2