aboutsummaryrefslogtreecommitdiff
path: root/bin/sleep
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2013-05-28 22:07:31 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2013-05-28 22:07:31 +0000
commitc2cfcb60632bb574e6e50535699913d6d085ef78 (patch)
tree3bec83639c75f4ef73930610bfa741cda65f44be /bin/sleep
parentc25673ffd6fb7718dcf8430c432a82dff72e42e3 (diff)
downloadsrc-c2cfcb60632bb574e6e50535699913d6d085ef78.tar.gz
src-c2cfcb60632bb574e6e50535699913d6d085ef78.zip
sleep: Improve nanosleep() error handling:
* Work around kernel bugs that cause a spurious [EINTR] return if a debugger (such as truss(1)) is attached. * Write an error message if an error other than [EINTR] occurs. PR: bin/178664
Notes
Notes: svn path=/head/; revision=251078
Diffstat (limited to 'bin/sleep')
-rw-r--r--bin/sleep/sleep.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/sleep/sleep.c b/bin/sleep/sleep.c
index fa7deb2f5ca5..0d41a4223f35 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>
@@ -87,8 +88,8 @@ main(int argc, char *argv[])
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);
}