diff options
Diffstat (limited to 'libs/libmdbx/src/test/osal-unix.cc')
-rw-r--r-- | libs/libmdbx/src/test/osal-unix.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libs/libmdbx/src/test/osal-unix.cc b/libs/libmdbx/src/test/osal-unix.cc index 8132e267ef..6661ae42c8 100644 --- a/libs/libmdbx/src/test/osal-unix.cc +++ b/libs/libmdbx/src/test/osal-unix.cc @@ -182,6 +182,9 @@ void osal_killall_actors(void) { } int osal_actor_poll(mdbx_pid_t &pid, unsigned timeout) { + struct timespec ts; + ts.tv_nsec = 0; + ts.tv_sec = timeout; retry: int status, options = WNOHANG; #ifdef WUNTRACED @@ -209,9 +212,16 @@ retry: } if (pid == 0) { - if (timeout && sleep(timeout)) + /* child still running */ + if (ts.tv_sec == 0 && ts.tv_nsec == 0) + ts.tv_nsec = 1; + if (nanosleep(&ts, &ts) == 0) { + /* timeout and no signal fomr child */ + pid = 0; + return 0; + } + if (errno == EINTR) goto retry; - return 0; } switch (errno) { |