diff options
| author | Simon J. Gerraty <sjg@FreeBSD.org> | 2013-09-05 20:18:59 +0000 |
|---|---|---|
| committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2013-09-05 20:18:59 +0000 |
| commit | d1d015864103b253b3fcb2f72a0da5b0cfeb31b6 (patch) | |
| tree | 22b131dceb13c3df96da594fbaadb693504797c7 /bin/sleep | |
| parent | 12d4083451fc39b3e831d4ea0bfa67d3b32cfb54 (diff) | |
| parent | b6f49c23a36f329cbf1e7f28078e17fd87f0e245 (diff) | |
Notes
Diffstat (limited to 'bin/sleep')
| -rw-r--r-- | bin/sleep/sleep.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/bin/sleep/sleep.c b/bin/sleep/sleep.c index fa7deb2f5ca5c..ca082723fbe18 100644 --- a/bin/sleep/sleep.c +++ b/bin/sleep/sleep.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include <ctype.h> #include <err.h> +#include <errno.h> #include <limits.h> #include <signal.h> #include <stdint.h> @@ -81,14 +82,20 @@ 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. */ warnx("about %d second(s) left out of the original %d", (int)time_to_sleep.tv_sec, (int)original); report_requested = 0; - } else - break; + } else if (errno != EINTR) + err(1, "nanosleep"); } return (0); } |
