diff options
author | Paul Irofti <pirofti@cvs.openbsd.org> | 2018-04-24 16:28:43 +0000 |
---|---|---|
committer | Paul Irofti <pirofti@cvs.openbsd.org> | 2018-04-24 16:28:43 +0000 |
commit | 42d8ef263eb22249f62ae63279fdc3c85980a0e8 (patch) | |
tree | c5ebaa7506e978533dd69ab567615a053fbaef01 /lib/libpthread | |
parent | 4fb053a8d5cca51b3ebdf34a236bd5320909952f (diff) |
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')
-rw-r--r-- | lib/libpthread/man/sem_wait.3 | 19 |
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 |