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.
This commit is contained in:
Valentine Krasnobaeva 2024-06-30 22:58:51 +02:00 committed by Willy Tarreau
parent 5bbcdc003a
commit df12791da3

View 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);