From 077e1ba486f8b0d260d447854bfb494b94dfcb8b Mon Sep 17 00:00:00 2001 From: jilles Date: Wed, 5 Jun 2013 20:15:18 +0000 Subject: sleep: Explain in a comment why the [EINTR] check is there. Suggested by: eadler --- bin/sleep/sleep.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bin') diff --git a/bin/sleep/sleep.c b/bin/sleep/sleep.c index 0d41a42..ca08272 100644 --- a/bin/sleep/sleep.c +++ b/bin/sleep/sleep.c @@ -82,6 +82,12 @@ main(int argc, char *argv[]) time_to_sleep.tv_nsec = 1e9 * (d - time_to_sleep.tv_sec); signal(SIGINFO, report_request); + + /* + * Note: [EINTR] is supposed to happen only when a signal was handled + * but the kernel also returns it when a ptrace-based debugger + * attaches. This is a bug but it is hard to fix. + */ while (nanosleep(&time_to_sleep, &time_to_sleep) != 0) { if (report_requested) { /* Reporting does not bother with nanoseconds. */ -- cgit v1.1