diff --git a/src/haproxy.c b/src/haproxy.c index 4fbead400..a3a36bbb1 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3920,11 +3920,16 @@ int main(int argc, char **argv) /* End of initialization for standalone and worker modes */ if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) { - devnullfd = open("/dev/null", (O_RDWR | O_CLOEXEC), 0); + devnullfd = open("/dev/null", O_RDWR, 0); if (devnullfd < 0) { ha_alert("Cannot open /dev/null\n"); exit(EXIT_FAILURE); } + if (fcntl(devnullfd, FD_CLOEXEC) != 0) { + ha_alert("Cannot make /dev/null CLOEXEC\n"); + close(devnullfd); + exit(EXIT_FAILURE); + } } /* applies the renice value in the worker or standalone after configuration parsing