Module Name: src
Committed By: drochner
Date: Mon May 31 11:02:24 UTC 2010
Modified Files:
src/lib/libc/sys: sigtimedwait.2 sigwait.c
Log Message:
another POSIX compliance fix: sigwait(3) should not use errno but
return the error code directly
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/sys/sigtimedwait.2
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/sys/sigwait.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/sys/sigtimedwait.2
diff -u src/lib/libc/sys/sigtimedwait.2:1.6 src/lib/libc/sys/sigtimedwait.2:1.7
--- src/lib/libc/sys/sigtimedwait.2:1.6 Sun May 30 19:31:39 2010
+++ src/lib/libc/sys/sigtimedwait.2 Mon May 31 11:02:24 2010
@@ -1,4 +1,4 @@
-.\" $NetBSD: sigtimedwait.2,v 1.6 2010/05/30 19:31:39 drochner Exp $
+.\" $NetBSD: sigtimedwait.2,v 1.7 2010/05/31 11:02:24 drochner Exp $
.\"
.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -94,13 +94,14 @@
.Fn sigwaitinfo
.Fa info
is updated with signal information, and the function returns the signal number.
+Otherwise, \-1 is returned and the global variable
+.Va errno
+indicates the error.
Upon successful completion of
.Fn sigwait
.Fa sig
is updated with ihe signal number, and the function returns 0.
-Otherwise, \-1 is returned and the global variable
-.Va errno
-indicates the error.
+Otherwise, a non-zero error code is returned,
.Sh ERRORS
.Fn sigwaitinfo
and
Index: src/lib/libc/sys/sigwait.c
diff -u src/lib/libc/sys/sigwait.c:1.3 src/lib/libc/sys/sigwait.c:1.4
--- src/lib/libc/sys/sigwait.c:1.3 Sun May 30 19:31:39 2010
+++ src/lib/libc/sys/sigwait.c Mon May 31 11:02:24 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: sigwait.c,v 1.3 2010/05/30 19:31:39 drochner Exp $ */
+/* $NetBSD: sigwait.c,v 1.4 2010/05/31 11:02:24 drochner Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sigwait.c,v 1.3 2010/05/30 19:31:39 drochner Exp $");
+__RCSID("$NetBSD: sigwait.c,v 1.4 2010/05/31 11:02:24 drochner Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -39,6 +39,7 @@
#include <sys/syscall.h>
#include <unistd.h>
#include <signal.h>
+#include <errno.h>
#ifdef __weak_alias
__weak_alias(sigwait,_sigwait)
@@ -53,11 +54,14 @@
int
_sigwait(const sigset_t * __restrict set, int * __restrict signum)
{
- int sig;
+ int saved_errno, new_errno, sig;
+ saved_errno = errno;
sig = __sigtimedwait(set, NULL, NULL);
+ new_errno = errno;
+ errno = saved_errno;
if (sig < 0)
- return (-1);
+ return (new_errno);
*signum = sig;
return (0);
}