diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/timeout/timeout.1 | 19 | ||||
-rw-r--r-- | usr.bin/timeout/timeout.c | 16 |
2 files changed, 27 insertions, 8 deletions
diff --git a/usr.bin/timeout/timeout.1 b/usr.bin/timeout/timeout.1 index 028fc62..70a9106 100644 --- a/usr.bin/timeout/timeout.1 +++ b/usr.bin/timeout/timeout.1 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 19, 2014 +.Dd Oct 28, 2014 .Dt TIMEOUT 1 .Os .Sh NAME @@ -108,7 +108,22 @@ is not set, an exit status of 124 is returned. .Pp If .Ar command -exits after receiving a signal, the exit status returned is the signal number plus 128. +exits after receiving a signal, the exit status returned is the signal number +plus 128. +.Pp +If +.Ar command +is an invalid command, the exit status returned is 126. +.Pp +If +.Ar command +is a non existing command, the exit status returned is 127. +.Pp +If an invalid parameter is passed to +.Fl s +or +.Fl k , +the exit status return is 125. .Sh SEE ALSO .Xr kill 1 , .Xr signal 3 diff --git a/usr.bin/timeout/timeout.c b/usr.bin/timeout/timeout.c index 8171600..214ab13 100644 --- a/usr.bin/timeout/timeout.c +++ b/usr.bin/timeout/timeout.c @@ -68,7 +68,7 @@ parse_duration(const char *duration) ret = strtod(duration, &end); if (ret == 0 && end == duration) - errx(EXIT_FAILURE, "invalid duration"); + errx(125, "invalid duration"); if (end == NULL || *end == '\0') return (ret); @@ -89,11 +89,11 @@ parse_duration(const char *duration) ret *= 60 * 60 * 24; break; default: - errx(EX_USAGE, "invalid duration"); + errx(125, "invalid duration"); } if (ret < 0 || ret >= 100000000UL) - errx(EX_USAGE, "invalid duration"); + errx(125, "invalid duration"); return (ret); } @@ -116,7 +116,7 @@ parse_signal(const char *str) return (i); } - errx(EX_USAGE, "invalid signal"); + errx(125, "invalid signal"); } static void @@ -260,8 +260,12 @@ main(int argc, char **argv) signal(SIGTTOU, SIG_DFL); error = execvp(argv[0], argv); - if (error == -1) - err(EX_UNAVAILABLE, "exec()"); + if (error == -1) { + if (errno == ENOENT) + err(127, "exec(%s)", argv[0]); + else + err(126, "exec(%s)", argv[0]); + } } if (sigprocmask(SIG_BLOCK, &signals.sa_mask, NULL) == -1) |