mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-29 23:19:20 +08:00
mdbx-test: fix sleep/child-signal handling.
Change-Id: Ibf1ac55b62b5cb3c835a5b1602a204e8eebbd89b
This commit is contained in:
parent
c6dccdc91a
commit
137f443e57
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user