summaryrefslogtreecommitdiff
path: root/usr.bin/time
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-08-21 13:38:03 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-08-21 13:38:03 +0000
commitae4fc655b0feb3dd0d1e9498569a706d80bf6d5e (patch)
tree9bac767902d93e9e0c2a2789c1f28a416159465f /usr.bin/time
parent1377d867350ce1de10ca363cc8f1aca2c4f95301 (diff)
Minor cleanup, joint work with Scott Cheloha <scottcheloha at gmail dot com>:
* Delete bogus error message and correct exit status when dying from SIGKILL. * Prefer warn(3) over perror(3) for clarity. * Return from main() rather than exit(3). * Simplify kill(getpid(), ...) to raise(...). * Drop obvious /* NOTREACHED */. No objections raised when shown on tech@.
Diffstat (limited to 'usr.bin/time')
-rw-r--r--usr.bin/time/time.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c
index f3e68f1124e..56c4a66a1ac 100644
--- a/usr.bin/time/time.c
+++ b/usr.bin/time/time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: time.c,v 1.24 2017/07/22 17:01:09 schwarze Exp $ */
+/* $OpenBSD: time.c,v 1.25 2017/08/21 13:38:02 schwarze Exp $ */
/* $NetBSD: time.c,v 1.7 1995/06/27 00:34:00 jtc Exp $ */
/*
@@ -67,7 +67,6 @@ main(int argc, char *argv[])
break;
default:
usage();
- /* NOTREACHED */
}
}
@@ -80,14 +79,12 @@ main(int argc, char *argv[])
clock_gettime(CLOCK_MONOTONIC, &before);
switch(pid = vfork()) {
case -1: /* error */
- perror("time");
- exit(1);
- /* NOTREACHED */
+ warn("fork");
+ return 1;
case 0: /* child */
execvp(*argv, argv);
- perror(*argv);
+ warn("%s", *argv);
_exit((errno == ENOENT) ? 127 : 126);
- /* NOTREACHED */
}
/* parent */
@@ -168,11 +165,11 @@ main(int argc, char *argv[])
if (exitonsig) {
if (signal(exitonsig, SIG_DFL) == SIG_ERR)
- perror("signal");
+ return 128 + exitonsig;
else
- kill(getpid(), exitonsig);
+ raise(exitonsig);
}
- exit(WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE);
+ return WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE;
}
__dead void