Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/sys another POSIX compliance fix: sigwait(3) should...



details:   https://anonhg.NetBSD.org/src/rev/3a4691fa7593
branches:  trunk
changeset: 755288:3a4691fa7593
user:      drochner <drochner%NetBSD.org@localhost>
date:      Mon May 31 11:02:24 2010 +0000

description:
another POSIX compliance fix: sigwait(3) should not use errno but
return the error code directly

diffstat:

 lib/libc/sys/sigtimedwait.2 |   9 +++++----
 lib/libc/sys/sigwait.c      |  12 ++++++++----
 2 files changed, 13 insertions(+), 8 deletions(-)

diffs (70 lines):

diff -r c02c796e2056 -r 3a4691fa7593 lib/libc/sys/sigtimedwait.2
--- a/lib/libc/sys/sigtimedwait.2       Mon May 31 09:46:25 2010 +0000
+++ b/lib/libc/sys/sigtimedwait.2       Mon May 31 11:02:24 2010 +0000
@@ -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
diff -r c02c796e2056 -r 3a4691fa7593 lib/libc/sys/sigwait.c
--- a/lib/libc/sys/sigwait.c    Mon May 31 09:46:25 2010 +0000
+++ b/lib/libc/sys/sigwait.c    Mon May 31 11:02:24 2010 +0000
@@ -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);
 }



Home | Main Index | Thread Index | Old Index