summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libthr/thread/thr_kern.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/libthr/thread/thr_kern.c b/lib/libthr/thread/thr_kern.c
index 3584246..1073ffd 100644
--- a/lib/libthr/thread/thr_kern.c
+++ b/lib/libthr/thread/thr_kern.c
@@ -137,6 +137,17 @@ _thread_suspend(pthread_t pthread, const struct timespec *abstime)
remaining = *abstime;
timespecsub(&remaining, &now);
ts = &remaining;
+
+ /*
+ * If the absolute timeout has already passed set the
+ * relative timeout to 0 sec. so that sigtimedwait()
+ * returns immediately.
+ * NOTE: timespecsub() makes sure the tv_nsec member >= 0.
+ */
+ if (ts->tv_sec < 0) {
+ ts->tv_sec = 0;
+ ts->tv_nsec = 0;
+ }
} else
ts = NULL;
OpenPOWER on IntegriCloud