git: 35503fe28eb5 - main - timeout(1): Use _exit(2) instead of err() in child if exec failed

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Wed, 16 Apr 2025 19:46:25 UTC
The branch main has been updated by bapt:

URL: https://cgit.FreeBSD.org/src/commit/?id=35503fe28eb51ef606cf4ae077a96b3c717199d3

commit 35503fe28eb51ef606cf4ae077a96b3c717199d3
Author:     Aaron LI <aly@aaronly.me>
AuthorDate: 2025-04-02 11:23:06 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2025-04-16 19:45:38 +0000

    timeout(1): Use _exit(2) instead of err() in child if exec failed
    
    * The child should _exit(2) instead of calling exit(3) via err(3) if the
      execvp() failed.
    * execvp(2) does not return except on error, so there is no need to
      check if the return value is -1.
    
    Obtained-from: OpenBSD (via DragonFly BSD)
---
 bin/timeout/timeout.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/bin/timeout/timeout.c b/bin/timeout/timeout.c
index 83893ba0a601..1817ef24995f 100644
--- a/bin/timeout/timeout.c
+++ b/bin/timeout/timeout.c
@@ -178,7 +178,7 @@ main(int argc, char **argv)
 {
 	int ch;
 	int foreground, preserve;
-	int error, pstat, status;
+	int pstat, status;
 	int killsig = SIGTERM;
 	size_t i;
 	pid_t pid, cpid;
@@ -280,13 +280,9 @@ main(int argc, char **argv)
 		signal(SIGTTIN, SIG_DFL);
 		signal(SIGTTOU, SIG_DFL);
 
-		error = execvp(argv[0], argv);
-		if (error == -1) {
-			if (errno == ENOENT)
-				err(EXIT_CMD_NOENT, "exec(%s)", argv[0]);
-			else
-				err(EXIT_CMD_ERROR, "exec(%s)", argv[0]);
-		}
+		execvp(argv[0], argv);
+		warn("exec(%s)", argv[0]);
+		_exit(errno == ENOENT ? EXIT_CMD_NOENT : EXIT_CMD_ERROR);
 	}
 
 	if (sigprocmask(SIG_BLOCK, &signals.sa_mask, NULL) == -1)