We currently use a mix of perror(3) and err(3).

In one case you can merge perror + exit into err, which is nice.

The warns, though, are not equivalent (you get a "time: " prefix), so
maybe this is too risky.

Putting it out here anyway.

--
Scott Cheloha

Index: usr.bin/time/time.c
===================================================================
RCS file: /cvs/src/usr.bin/time/time.c,v
retrieving revision 1.22
diff -u -p -r1.22 time.c
--- usr.bin/time/time.c 13 Jul 2017 06:39:54 -0000      1.22
+++ usr.bin/time/time.c 14 Jul 2017 00:24:59 -0000
@@ -82,12 +82,11 @@ main(int argc, char *argv[])
        clock_gettime(CLOCK_MONOTONIC, &before);
        switch(pid = vfork()) {
        case -1:                        /* error */
-               perror("time");
-               exit(1);
+               err(1, NULL);
                /* NOTREACHED */
        case 0:                         /* child */
                execvp(*argv, argv);
-               perror(*argv);
+               warn("%s", *argv);
                _exit((errno == ENOENT) ? 127 : 126);
                /* NOTREACHED */
        }
@@ -170,7 +169,7 @@ main(int argc, char *argv[])
 
        if (exitonsig) {
                if (signal(exitonsig, SIG_DFL) == SIG_ERR)
-                       perror("signal");
+                       warn("signal");
                else
                        kill(getpid(), exitonsig);
        }

Reply via email to