timeout: eliminate usage of sysexits

It brings no value at all the sysexits and maybe misleading as the
return value of timeout(1) matters.
This commit is contained in:
Baptiste Daroussin 2021-10-20 10:39:34 +02:00
parent 6ae38ab453
commit 68914dab43

View File

@ -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)