[haiku-commits] r41734 - haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 25 May 2011 04:10:27 +0200 (CEST)

Author: bonefish
Date: 2011-05-25 04:10:26 +0200 (Wed, 25 May 2011)
New Revision: 41734
Changeset: https://dev.haiku-os.org/changeset/41734

Modified:
   
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/sigtimedwait.cpp
   
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/sigwait.cpp
Log:
Fixed sigwait() and sigtimedwait(). sigwait() returns 0 on success and the error
code on failure (no errno). sigtimedwait() returns the signal number on success
and -1 on failure (setting errno).


Modified: 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/sigtimedwait.cpp
===================================================================
--- 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/sigtimedwait.cpp
  2011-05-25 02:00:12 UTC (rev 41733)
+++ 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/sigtimedwait.cpp
  2011-05-25 02:10:26 UTC (rev 41734)
@@ -17,6 +17,11 @@
 sigtimedwait(const sigset_t* set, siginfo_t* info,
        const struct timespec* timeout)
 {
+       // make info non-NULL to simplify things
+       siginfo_t stackInfo;
+       if (info == NULL)
+               info = &stackInfo;
+
        // translate the timeout
        uint32 flags;
     bigtime_t timeoutMicros;
@@ -30,5 +35,9 @@
                timeoutMicros = 0;
        }
 
-       RETURN_AND_SET_ERRNO(_kern_sigwait(set, info, flags, timeoutMicros));
+       status_t error = _kern_sigwait(set, info, flags, timeoutMicros);
+       if (error != B_OK)
+               RETURN_AND_SET_ERRNO(error);
+
+       return info->si_signo;
 }

Modified: 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/sigwait.cpp
===================================================================
--- 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/sigwait.cpp
       2011-05-25 02:00:12 UTC (rev 41733)
+++ 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/sigwait.cpp
       2011-05-25 02:10:26 UTC (rev 41734)
@@ -9,18 +9,22 @@
 
 #include <symbol_versioning.h>
 
+#include <syscalls.h>
+
 #include "signal_private.h"
 
 
 int
 __sigwait_beos(const sigset_t_beos* beosSet, int* _signal)
 {
+       // convert the given signal set and call the current version
        sigset_t set = from_beos_sigset(*beosSet);
-       if (__sigwait_current(&set, _signal) != 0)
-               return -1;
+       int error = __sigwait_current(&set, _signal);
+       if (error != 0)
+               return error;
 
        // translate SIGBUS to SIGSEGV
-       if (_signal != NULL && *_signal == SIGBUS)
+       if (*_signal == SIGBUS)
                *_signal = SIGSEGV;
 
        return 0;
@@ -31,9 +35,9 @@
 __sigwait_current(const sigset_t* set, int* _signal)
 {
        siginfo_t info;
-       int result = sigtimedwait(set, &info, NULL);
-       if (result != 0)
-               return result;
+       status_t error = _kern_sigwait(set, &info, 0, 0);
+       if (error != B_OK)
+               return error;
 
        *_signal = info.si_signo;
        return 0;


Other related posts:

  • » [haiku-commits] r41734 - haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal - ingo_weinhold