diff --git a/src/xpdev/semwrap.c b/src/xpdev/semwrap.c index f86617926b16038e6a58ffaf95ee0999898707f3..af89da82dc7930518928a27282be1e870a868fc4 100644 --- a/src/xpdev/semwrap.c +++ b/src/xpdev/semwrap.c @@ -55,8 +55,8 @@ sem_trywait_block(sem_t *sem, unsigned long timeout) abstime.tv_nsec=(currtime.tv_usec*1000 + timeout*1000000)%1000000000; retval=sem_timedwait(sem, &abstime); - if(retval==ETIMEDOUT) - errno=EAGAIN; + if(retval && errno==ETIMEDOUT) + retval=EAGAIN; return retval; } #endif diff --git a/src/xpdev/xpsem.c b/src/xpdev/xpsem.c index 3a75a470e481fac08f86b4437d7750800aa2700f..e588911b175d5ef81d9e6998a2f551c2ddc0773e 100644 --- a/src/xpdev/xpsem.c +++ b/src/xpdev/xpsem.c @@ -253,8 +253,10 @@ xp_sem_timedwait(xp_sem_t *sem, const struct timespec *abs_timeout) (*sem)->nwaiters++; retval=pthread_cond_timedwait(&(*sem)->gtzero, &(*sem)->lock, abs_timeout); (*sem)->nwaiters--; - if(retval) - break; + if(retval) { + errno=retval; + retval=-1; + } } if(retval==0) (*sem)->count--;