From df12791da3bff0c63d37effba62e34722b72d3e8 Mon Sep 17 00:00:00 2001 From: Valentine Krasnobaeva Date: Sun, 30 Jun 2024 22:58:51 +0200 Subject: [PATCH] MINOR: startup: add O_CLOEXEC flag to open /dev/null As master process performs execvp() syscall to handle USR2 and HUP signals in mworker_reexec(), let's add O_CLOEXEC flag, when we open '/dev/null' in order to avoid fd leak. This a preparation step to refactor master-worker logic. See more details in the next commits. --- src/haproxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/haproxy.c b/src/haproxy.c index 11fe16d883..50ec6fcb14 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3704,7 +3704,7 @@ int main(int argc, char **argv) } if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) { - devnullfd = open("/dev/null", O_RDWR, 0); + devnullfd = open("/dev/null", (O_RDWR | O_CLOEXEC), 0); if (devnullfd < 0) { ha_alert("Cannot open /dev/null\n"); exit(EXIT_FAILURE); -- 2.47.3