summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2013-04-16 20:26:31 +0000
committerjhb <jhb@FreeBSD.org>2013-04-16 20:26:31 +0000
commit0ed1bc2e92ec2a84dd3da0bc98f296edaebc318e (patch)
tree2790edcc2056d97f1f5ab28bba61ab26eb53b800
parent2f4d81f0936ee8936392573dd361b4260a1f393c (diff)
downloadFreeBSD-src-0ed1bc2e92ec2a84dd3da0bc98f296edaebc318e.zip
FreeBSD-src-0ed1bc2e92ec2a84dd3da0bc98f296edaebc318e.tar.gz
- Document that sem_wait() can fail with EINTR if it is interrupted by a
signal. - Fix the old ksem implementation for POSIX semaphores to not restart sem_wait() or sem_timedwait() if interrupted by a signal. MFC after: 1 week
-rw-r--r--lib/libc/gen/sem_wait.310
-rw-r--r--sys/kern/uipc_sem.c2
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/libc/gen/sem_wait.3 b/lib/libc/gen/sem_wait.3
index 18e9586..b8303d4 100644
--- a/lib/libc/gen/sem_wait.3
+++ b/lib/libc/gen/sem_wait.3
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 15, 2000
+.Dd April 16, 2013
.Dt SEM_WAIT 3
.Os
.Sh NAME
@@ -75,6 +75,14 @@ points to an invalid semaphore.
.El
.Pp
Additionally,
+.Fn sem_wait
+will fail if:
+.Bl -tag -width Er
+.Pp
+.It Bq Er EINTR
+A signal interrupted this function.
+.El
+Additionally,
.Fn sem_trywait
will fail if:
.Bl -tag -width Er
diff --git a/sys/kern/uipc_sem.c b/sys/kern/uipc_sem.c
index 509f32e..0ea84fd 100644
--- a/sys/kern/uipc_sem.c
+++ b/sys/kern/uipc_sem.c
@@ -846,6 +846,8 @@ 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);
OpenPOWER on IntegriCloud