diff options
author | jilles <jilles@FreeBSD.org> | 2013-04-19 10:16:00 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2013-04-19 10:16:00 +0000 |
commit | be7967ddcc79e167b9d131caefef8bed980385af (patch) | |
tree | ec1facf95300fccb6ce1c320d05d8857cf846d56 /sys/kern/uipc_sem.c | |
parent | 8a41f6ac5bb23e37a0202a35418370cb7b725138 (diff) | |
download | FreeBSD-src-be7967ddcc79e167b9d131caefef8bed980385af.zip FreeBSD-src-be7967ddcc79e167b9d131caefef8bed980385af.tar.gz |
sem: Restart the POSIX sem_* calls after signals with SA_RESTART set.
Programs often do not expect an [EINTR] return from sem_wait() and POSIX
only allows it if the signal was installed without SA_RESTART. The timeout
in sem_timedwait() is absolute so it can be restarted normally.
The umtx call can be invoked with a relative timeout and in that case
[ERESTART] must be changed to [EINTR]. However, libc does not do this.
The old POSIX semaphore implementation did this correctly (before r249566),
unlike the new umtx one.
It may be desirable to avoid [EINTR] completely, which matches the pthread
functions and is explicitly permitted by POSIX. However, the kernel must
return [EINTR] at least for signals with SA_RESTART clear, otherwise pthread
cancellation will not abort a semaphore wait. In this commit, only restore
the 8.x behaviour which is also permitted by POSIX.
Discussed with: jhb
MFC after: 1 week
Diffstat (limited to 'sys/kern/uipc_sem.c')
-rw-r--r-- | sys/kern/uipc_sem.c | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/sys/kern/uipc_sem.c b/sys/kern/uipc_sem.c index 0ea84fd..509f32e 100644 --- a/sys/kern/uipc_sem.c +++ b/sys/kern/uipc_sem.c @@ -846,8 +846,6 @@ kern_sem_wait(struct thread *td, semid_t id, int tryflag, err: mtx_unlock(&sem_lock); fdrop(fp, td); - if (error == ERESTART) - error = EINTR; DP(("<<< kern_sem_wait leaving, pid=%d, error = %d\n", (int)td->td_proc->p_pid, error)); return (error); |