diff --git a/src/checks.c b/src/checks.c index c4ac947b6..60f12264d 100644 --- a/src/checks.c +++ b/src/checks.c @@ -1836,6 +1836,14 @@ static int connect_proc_chk(struct task *t) if (pid == 0) { /* Child */ extern char **environ; + int fd; + + /* close all FDs. Keep stdin/stdout/stderr in verbose mode */ + fd = (global.mode & (MODE_QUIET|MODE_VERBOSE)) == MODE_QUIET ? 0 : 3; + + while (fd < global.rlimit_nofile) + close(fd++); + environ = check->envp; extchk_setenv(check, EXTCHK_HAPROXY_SERVER_CURCONN, ultoa_r(s->cur_sess, buf, sizeof(buf))); execvp(px->check_command, check->argv);