In semop man page I have found in BUGS section the following explanations:
<quote>
When a process terminates, its set of associated semadj structures is used
to undo the effect of all of the semaphore operations it performed with
the SEM_UNDO flag. This raises a difficulty: if one (or more) of these
semaphore adjustments would result in an attempt to decrease a
semaphore's value below zero, what should an implementation do? One
possible approach would be to block until all the semaphore adjustments
could be performed. This is however undesirable since it could force
process termination to block for arbitrarily long periods. Another
possibility is that such semaphore adjustments could be ignored
altogether (somewhat analogously to failing when IPC_NOWAIT is specified
for a semaphore operation). Linux adopts a third approach: decreasing the
semaphore value as far as possible (i.e., to zero) and allowing
process termination to proceed immediately.
</quote>
I have found fourth approach: semop() should fail if the operation would
result with semadj value less than new semaphore value. This may occur only
when semop() attempts to decrease semaphore value without SEM_UNDO flag
set.
What do you think about this approach ? In my opinion it is the best one. If
so, why is it not implemented ? Does anybody see something wrong there ?
Rafal
--
sed -e s/s/a/g <my_address >my_right_address