]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: startup: add O_CLOEXEC flag to open /dev/null
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Sun, 30 Jun 2024 20:58:51 +0000 (22:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Oct 2024 20:00:58 +0000 (22:00 +0200)
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

index 11fe16d8832f299e76a9e4216689aa4369abe34b..50ec6fcb14064cfaec473ea508f0103d01e1778d 100644 (file)
@@ -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);