Don't leak /dev/null file descriptor (#874)

This commit is contained in:
zakk4223
2024-02-12 12:31:12 -05:00
committed by GitHub
parent 11d35160ff
commit 96f3f685e4

10
cfg.cpp
View File

@@ -409,7 +409,15 @@ static void ini_parse(int alt, const char *vmode)
int eof;
if (!orig_stdout) orig_stdout = stdout;
if(!dev_null) dev_null = fopen("/dev/null", "w");
if(!dev_null)
{
dev_null = fopen("/dev/null", "w");
if (dev_null) {
int null_fd = fileno(dev_null);
if (null_fd >= 0) fcntl(null_fd, F_SETFD, FD_CLOEXEC);
}
}
ini_parser_debugf("Start INI parser for core \"%s\"(%s), video mode \"%s\".", user_io_get_core_name(0), user_io_get_core_name(1), vmode);