Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Mar 2023 23:31:26 -0600
From:      Kyle Evans <kevans@freebsd.org>
To:        Kyle Evans <kevans@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org,  dev-commits-src-main@freebsd.org
Subject:   Re: git: d6c398d882b6 - main - daemon: add braces to while loop
Message-ID:  <CACNAnaGHs41u=cGA=%2BSTM5sRdGkJhwbv83jXHmJsgeEu0OzK-g@mail.gmail.com>
In-Reply-To: <202303030517.3235HRmW019673@gitrepo.freebsd.org>
References:  <202303030517.3235HRmW019673@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Mar 2, 2023 at 11:17=E2=80=AFPM Kyle Evans <kevans@freebsd.org> wro=
te:
>
> The branch main has been updated by kevans:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=3Dd6c398d882b61e02e6f061be81=
886b9675f3fb5c
>
> commit d6c398d882b61e02e6f061be81886b9675f3fb5c
> Author:     Ihor Antonov <ihor@antonovs.family>
> AuthorDate: 2023-03-03 05:17:02 +0000
> Commit:     Kyle Evans <kevans@FreeBSD.org>
> CommitDate: 2023-03-03 05:17:02 +0000
>
>     daemon: add braces to while loop
>
>     Reviewed by:    kevans
>     Pull Request:   https://github.com/freebsd/freebsd-src/pull/672
> ---

Sorry, caught this once but forgot to fix it again when I redid the
branch pre-commit. Obviously there's more than just brace-loop here.
:-( pfd -> pipe_fd rename for clarity.

Thanks,

Kyle Evans

>  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 =3D NULL;
>         int ch =3D 0;
>         int keep_cur_workdir =3D 1;
> -       int pfd[2] =3D { -1, -1 };
> +       int pipe_fd[2] =3D { -1, -1 };
>         int restart =3D 0;
>         int stdmask =3D STDOUT_FILENO | STDERR_FILENO;
>         struct log_params logparams =3D {
> @@ -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) =3D=3D -1=
) {
> +                               if (dup2(pipe_fd[1], STDERR_FILENO) =3D=
=3D -1) {
>                                         err(1, "dup2");
>                                 }
>                         }
>                         if (stdmask & STDOUT_FILENO) {
> -                               if (dup2(pfd[1], STDOUT_FILENO) =3D=3D -1=
) {
> +                               if (dup2(pipe_fd[1], STDOUT_FILENO) =3D=
=3D -1) {
>                                         err(1, "dup2");
>                                 }
>                         }
> -                       if (pfd[1] !=3D STDERR_FILENO &&
> -                           pfd[1] !=3D STDOUT_FILENO) {
> -                               close(pfd[1]);
> +                       if (pipe_fd[1] !=3D STDERR_FILENO &&
> +                           pipe_fd[1] !=3D STDOUT_FILENO) {
> +                               close(pipe_fd[1]);
>                         }
>                 }
>                 execvp(argv[0], argv);
> @@ -424,8 +424,8 @@ restart:
>                 warn("sigprocmask");
>                 goto exit;
>         }
> -       close(pfd[1]);
> -       pfd[1] =3D -1;
> +       close(pipe_fd[1]);
> +       pipe_fd[1] =3D -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 =3D !listen_child(pfd[0], &logparams);
> +               child_eof =3D !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] =3D -1;
> +               close(pipe_fd[0]);
> +               pipe_fd[0] =3D -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();
>         }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACNAnaGHs41u=cGA=%2BSTM5sRdGkJhwbv83jXHmJsgeEu0OzK-g>