summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/man/sem_wait.3
diff options
context:
space:
mode:
authorpirofti <pirofti@openbsd.org>2018-04-24 16:28:42 +0000
committerpirofti <pirofti@openbsd.org>2018-04-24 16:28:42 +0000
commitbda456ccd11759e253796707fd980cfc75ecc76d (patch)
treeb010de26d6610adb828989702c7b32def9192bc8 /lib/libpthread/man/sem_wait.3
parentPush NET_LOCK down in the default ifioctl case. (diff)
downloadwireguard-openbsd-bda456ccd11759e253796707fd980cfc75ecc76d.tar.xz
wireguard-openbsd-bda456ccd11759e253796707fd980cfc75ecc76d.zip
Validate timespec and return ECANCELED when interrupted with SA_RESTART.
Discussing with mpi@ and guenther@, we decided to first fix the existing semaphore implementation with regards to SA_RESTART and POSIX compliant returns in the case where we deal with restartable signals. Currently we return EINTR everywhere which is mostly incorrect as the user can not know if she needs to recall the syscall or not. Return ECANCELED to signal that SA_RESTART was set and EINTR otherwise. Regression tests pass and so does the posixsuite. Timespec validation bits are needed to pass the later. OK mpi@, guenther@
Diffstat (limited to 'lib/libpthread/man/sem_wait.3')
-rw-r--r--lib/libpthread/man/sem_wait.319
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/libpthread/man/sem_wait.3 b/lib/libpthread/man/sem_wait.3
index 31c091eda89..1d91acf16d9 100644
--- a/lib/libpthread/man/sem_wait.3
+++ b/lib/libpthread/man/sem_wait.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sem_wait.3,v 1.9 2013/06/05 03:44:50 tedu Exp $
+.\" $OpenBSD: sem_wait.3,v 1.10 2018/04/24 16:28:42 pirofti Exp $
.\"
.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>.
.\" All rights reserved.
@@ -28,7 +28,7 @@
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/libc_r/man/sem_wait.3,v 1.8 2001/10/01 16:09:09 ru Exp $
-.Dd $Mdocdate: June 5 2013 $
+.Dd $Mdocdate: April 24 2018 $
.Dt SEM_WAIT 3
.Os
.Sh NAME
@@ -86,9 +86,24 @@ points to an invalid semaphore.
.El
.Pp
Additionally,
+.Fn sem_wait
+and
+.Fn sem_timedwait
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EINTR
+The call was interrupted by a signal.
+.El
+.Pp
+Additionally,
.Fn sem_timedwait
will fail if:
.Bl -tag -width Er
+.It Bq Er EINVAL
+.Fa abstime
+was
+.Dv NULL
+or specified a nanosecond value less than zero or greater than 1000 million.
.It Bq Er ETIMEDOUT
The semaphore value was zero and could not be decremented before
.Fa abstime