mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-01 05:44:43 +08:00
libobs/util: Prevent leaking pipe file descriptors to subprocesses
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user