mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-31 11:08:22 +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) {
|
int osal_actor_poll(mdbx_pid_t &pid, unsigned timeout) {
|
||||||
|
struct timespec ts;
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
ts.tv_sec = timeout;
|
||||||
retry:
|
retry:
|
||||||
int status, options = WNOHANG;
|
int status, options = WNOHANG;
|
||||||
#ifdef WUNTRACED
|
#ifdef WUNTRACED
|
||||||
@ -209,10 +212,17 @@ retry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
if (timeout && sleep(timeout))
|
/* child still running */
|
||||||
goto retry;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (errno == EINTR)
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
case EINTR:
|
case EINTR:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user