diff --git a/src/cli.c b/src/cli.c index dea6c36f1..5a19be559 100644 --- a/src/cli.c +++ b/src/cli.c @@ -2659,7 +2659,7 @@ static int _send_status(char **args, char *payload, struct appctx *appctx, void (global.mode & MODE_DAEMON)) { /* detach from the tty, this is required to properly daemonize. */ if ((getenv("HAPROXY_MWORKER_REEXEC") == NULL)) - stdio_quiet(-1); + stdio_quiet(devnullfd); global.mode &= ~MODE_VERBOSE; global.mode |= MODE_QUIET; /* ensure that we won't say anything from now */ } diff --git a/src/haproxy.c b/src/haproxy.c index 28e9c1dea..09fe465e6 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2496,7 +2496,7 @@ static void step_init_4(void) } else { if ((global.mode & MODE_QUIET) && !(global.mode & MODE_VERBOSE)) { /* detach from the tty */ - stdio_quiet(-1); + stdio_quiet(devnullfd); } } @@ -2596,7 +2596,7 @@ static void run_master_in_recovery_mode(int argc, char **argv) (global.mode & MODE_DAEMON)) { /* detach from the tty, this is required to properly daemonize. */ if ((getenv("HAPROXY_MWORKER_REEXEC") == NULL)) - stdio_quiet(-1); + stdio_quiet(devnullfd); global.mode &= ~MODE_VERBOSE; global.mode |= MODE_QUIET; /* ensure that we won't say anything from now */ } @@ -3551,9 +3551,9 @@ int main(int argc, char **argv) stdio_quiet(devnullfd); global.mode &= ~MODE_VERBOSE; global.mode |= MODE_QUIET; /* ensure that we won't say anything from now */ - close(devnullfd); - devnullfd = -1; } + close(devnullfd); + devnullfd = -1; pid = getpid(); /* update pid */ /* This call is expensive, as it creates a new poller, scans and tries