git: 3f0b048a24bc - stable/13 - daemon: add braces to while loop
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 17 Mar 2023 21:01:39 UTC
The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=3f0b048a24bcd0ea691bca5a012d5c5cd5203f51 commit 3f0b048a24bcd0ea691bca5a012d5c5cd5203f51 Author: Ihor Antonov <ihor@antonovs.family> AuthorDate: 2023-03-03 05:17:02 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2023-03-17 21:01:03 +0000 daemon: add braces to while loop Reviewed by: kevans Pull Request: https://github.com/freebsd/freebsd-src/pull/672 (cherry picked from commit d6c398d882b61e02e6f061be81886b9675f3fb5c) --- usr.sbin/daemon/daemon.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c index 2274a3e253a0..d1efebd0fcc2 100644 --- a/usr.sbin/daemon/daemon.c +++ b/usr.sbin/daemon/daemon.c @@ -154,7 +154,7 @@ main(int argc, char *argv[]) const char *user = NULL; int ch = 0; int keep_cur_workdir = 1; - int pfd[2] = { -1, -1 }; + int pipe_fd[2] = { -1, -1 }; int restart = 0; int stdmask = STDOUT_FILENO | STDERR_FILENO; struct log_params logparams = { @@ -360,7 +360,7 @@ main(int argc, char *argv[]) goto exit; } restart: - if (pipe(pfd)) { + if (pipe(pipe_fd)) { err(1, "pipe"); } /* @@ -389,23 +389,23 @@ restart: * and dup'd pipes. */ if (supervision_enabled) { - close(pfd[0]); + close(pipe_fd[0]); if (sigprocmask(SIG_SETMASK, &mask_orig, NULL)) { err(1, "sigprogmask"); } if (stdmask & STDERR_FILENO) { - if (dup2(pfd[1], STDERR_FILENO) == -1) { + if (dup2(pipe_fd[1], STDERR_FILENO) == -1) { err(1, "dup2"); } } if (stdmask & STDOUT_FILENO) { - if (dup2(pfd[1], STDOUT_FILENO) == -1) { + if (dup2(pipe_fd[1], STDOUT_FILENO) == -1) { err(1, "dup2"); } } - if (pfd[1] != STDERR_FILENO && - pfd[1] != STDOUT_FILENO) { - close(pfd[1]); + if (pipe_fd[1] != STDERR_FILENO && + pipe_fd[1] != STDOUT_FILENO) { + close(pipe_fd[1]); } } execvp(argv[0], argv); @@ -424,8 +424,8 @@ restart: warn("sigprocmask"); goto exit; } - close(pfd[1]); - pfd[1] = -1; + close(pipe_fd[1]); + pipe_fd[1] = -1; setproctitle("%s[%d]", title, (int)pid); /* @@ -463,8 +463,9 @@ restart: warn("sigprocmask"); goto exit; } - while (!terminate && !child_gone) + while (!terminate && !child_gone) { sigsuspend(&mask_orig); + } if (sigprocmask(SIG_UNBLOCK, &mask_susp, NULL)) { warn("sigprocmask"); goto exit; @@ -477,7 +478,7 @@ restart: goto exit; } - child_eof = !listen_child(pfd[0], &logparams); + child_eof = !listen_child(pipe_fd[0], &logparams); if (sigprocmask(SIG_UNBLOCK, &mask_read, NULL)) { warn("sigprocmask"); @@ -493,14 +494,14 @@ restart: goto exit; } if (restart && !terminate) { - close(pfd[0]); - pfd[0] = -1; + close(pipe_fd[0]); + pipe_fd[0] = -1; goto restart; } exit: close(logparams.output_fd); - close(pfd[0]); - close(pfd[1]); + close(pipe_fd[0]); + close(pipe_fd[1]); if (logparams.syslog_enabled) { closelog(); }