Date: Wed, 20 Oct 2021 09:04:13 GMT From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 68914dab436a - main - timeout: eliminate usage of sysexits Message-ID: <202110200904.19K94DTj011789@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=68914dab436acf166b8f851c4fa0acecb7c7c510 commit 68914dab436acf166b8f851c4fa0acecb7c7c510 Author: Baptiste Daroussin <bapt@FreeBSD.org> AuthorDate: 2021-10-20 08:39:34 +0000 Commit: Baptiste Daroussin <bapt@FreeBSD.org> CommitDate: 2021-10-20 08:39:34 +0000 timeout: eliminate usage of sysexits It brings no value at all the sysexits and maybe misleading as the return value of timeout(1) matters. --- usr.bin/timeout/timeout.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/usr.bin/timeout/timeout.c b/usr.bin/timeout/timeout.c index d682541e9162..6af795ba7408 100644 --- a/usr.bin/timeout/timeout.c +++ b/usr.bin/timeout/timeout.c @@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sysexits.h> #include <unistd.h> #define EXIT_TIMEOUT 124 @@ -58,7 +57,7 @@ usage(void) " [--kill-after time | -k time] [--foreground] <duration> <command>" " <arg ...>\n", getprogname()); - exit(EX_USAGE); + exit(EXIT_FAILURE); } static double @@ -75,7 +74,7 @@ parse_duration(const char *duration) return (ret); if (end != NULL && *(end + 1) != '\0') - errx(EX_USAGE, "invalid duration"); + errx(125, "invalid duration"); switch (*end) { case 's': @@ -156,7 +155,7 @@ set_interval(double iv) tim.it_value.tv_usec = (suseconds_t)(iv * 1000000UL); if (setitimer(ITIMER_REAL, &tim, NULL) == -1) - err(EX_OSERR, "setitimer()"); + err(EXIT_FAILURE, "setitimer()"); } int @@ -229,7 +228,7 @@ main(int argc, char **argv) if (!foreground) { /* Acquire a reaper */ if (procctl(P_PID, getpid(), PROC_REAP_ACQUIRE, NULL) == -1) - err(EX_OSERR, "Fail to acquire the reaper"); + err(EXIT_FAILURE, "Fail to acquire the reaper"); } memset(&signals, 0, sizeof(signals)); @@ -247,14 +246,14 @@ main(int argc, char **argv) for (i = 0; i < sizeof(signums) / sizeof(signums[0]); i ++) if (signums[i] != -1 && signums[i] != 0 && sigaction(signums[i], &signals, NULL) == -1) - err(EX_OSERR, "sigaction()"); + err(EXIT_FAILURE, "sigaction()"); signal(SIGTTIN, SIG_IGN); signal(SIGTTOU, SIG_IGN); pid = fork(); if (pid == -1) - err(EX_OSERR, "fork()"); + err(EXIT_FAILURE, "fork()"); else if (pid == 0) { /* child process */ signal(SIGTTIN, SIG_DFL); @@ -270,7 +269,7 @@ main(int argc, char **argv) } if (sigprocmask(SIG_BLOCK, &signals.sa_mask, NULL) == -1) - err(EX_OSERR, "sigprocmask()"); + err(EXIT_FAILURE, "sigprocmask()"); /* parent continues here */ set_interval(first_kill); @@ -344,7 +343,7 @@ main(int argc, char **argv) while (!child_done && wait(&pstat) == -1) { if (errno != EINTR) - err(EX_OSERR, "waitpid()"); + err(EXIT_FAILURE, "waitpid()"); } if (!foreground)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202110200904.19K94DTj011789>