about summary refs log tree commit homepage
path: root/sig.c
diff options
context:
space:
mode:
Diffstat (limited to 'sig.c')
-rw-r--r--sig.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/sig.c b/sig.c
index c04117a..cfbffc2 100644
--- a/sig.c
+++ b/sig.c
@@ -32,23 +32,33 @@ void mog_intr_enable(void)
  * would increase the size of the executable
  */
 #ifdef HAVE_PPOLL
-static void sleeper(struct timespec *tsp, const sigset_t *sigmask)
+static int sleeper(struct timespec *tsp, const sigset_t *sigmask)
 {
-        if (ppoll(NULL, 0, tsp, sigmask) < 0)
-                assert((errno == EINTR || errno == ENOMEM) &&
+        int err = 0;
+
+        if (ppoll(NULL, 0, tsp, sigmask) < 0) {
+                err = errno;
+                assert((err == EINTR || err == ENOMEM) &&
                        "BUG in ppoll usage");
+        }
+        return err;
 }
 #else /* PSELECT */
-static void sleeper(struct timespec *tsp, const sigset_t *sigmask)
+static int sleeper(struct timespec *tsp, const sigset_t *sigmask)
 {
-        if (pselect(0, NULL, NULL, NULL, tsp, sigmask) < 0)
-                assert((errno == EINTR || errno == ENOMEM) &&
+        int err = 0;
+
+        if (pselect(0, NULL, NULL, NULL, tsp, sigmask) < 0) {
+                err = errno;
+                assert((err == EINTR || err == ENOMEM) &&
                        "BUG in pselect usage");
+        }
+        return err;
 }
 #endif /* PSELECT */
 
 /* thread-safe, interruptible sleep, negative seconds -> sleep forever */
-void mog_sleep(long seconds)
+int mog_sleep(long seconds)
 {
         struct timespec ts;
         struct timespec *tsp;
@@ -61,5 +71,5 @@ void mog_sleep(long seconds)
                 tsp = &ts;
         }
 
-        sleeper(tsp, &mog_emptyset);
+        return sleeper(tsp, &mog_emptyset);
 }