Few weeks bump.
Any feedback on this fabulous Scott Cheloha/ingo@ collaboration?
Slightly re-tweaked patch below; while here:
kill(getpid(), sig) -> raise(sig)
I didn't even know there was a raise(3) function until this weekend,
they really did think of everything.
--
Scott Cheloha
Index: time.c
===================================================================
RCS file: /cvs/src/usr.bin/time/time.c,v
retrieving revision 1.24
diff -u -p -r1.24 time.c
--- time.c 22 Jul 2017 17:01:09 -0000 1.24
+++ time.c 20 Aug 2017 22:12:39 -0000
@@ -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