libobs/util: Prevent leaking pipe file descriptors to subprocesses

This commit is contained in:
Exeldro
2024-04-19 21:18:17 +02:00
committed by Lain
parent 2edc555af7
commit 65295eaf93
+6
View File
@@ -19,6 +19,7 @@
#include <unistd.h>
#include <errno.h>
#include <spawn.h>
#include <fcntl.h>
#include "bmem.h"
#include "pipe.h"
@@ -66,6 +67,11 @@ os_process_pipe_t *os_process_pipe_create(const char *cmd_line,
return NULL;
}
fcntl(mainfds[0], F_SETFD, FD_CLOEXEC);
fcntl(mainfds[1], F_SETFD, FD_CLOEXEC);
fcntl(errfds[0], F_SETFD, FD_CLOEXEC);
fcntl(errfds[1], F_SETFD, FD_CLOEXEC);
if (process_pipe.read_pipe) {
posix_spawn_file_actions_addclose(&file_actions, mainfds[0]);
if (mainfds[1] != STDOUT_FILENO) {