Skip to content

Commit 898f590

Browse files
committed
main: retry nanosleep when we get EINTR
We get EINTR a lot with `-n` as we are interrupted by SIGCHLD. This meant the sleep was aborted far too soon.
1 parent 509df07 commit 898f590

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ static void poll_loop(const poll_loop_args_t* args)
444444
unsigned sleep_ms = sleep_time_ms(args, &m);
445445
debug("adaptive sleep time: %d ms\n", sleep_ms);
446446
struct timespec req = { .tv_sec = (time_t)(sleep_ms / 1000), .tv_nsec = (sleep_ms % 1000) * 1000000 };
447-
nanosleep(&req, NULL);
447+
while(nanosleep(&req, &req) == -1 && errno == EINTR);
448448
report_countdown_ms -= (int)sleep_ms;
449449
}
450450
}

0 commit comments

Comments
 (0)