aboutsummaryrefslogtreecommitdiff
path: root/src/common/platform
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/platform')
-rw-r--r--src/common/platform/unix/PosixSpawnSubProcess.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common/platform/unix/PosixSpawnSubProcess.cpp b/src/common/platform/unix/PosixSpawnSubProcess.cpp
index fba536e5..1d69f54a 100644
--- a/src/common/platform/unix/PosixSpawnSubProcess.cpp
+++ b/src/common/platform/unix/PosixSpawnSubProcess.cpp
@@ -107,6 +107,15 @@ void PosixSpawnSubProcess::PlatformCreateProcess() {
error = posix_spawn_file_actions_adddup2(
&file_actions, stderr_pipe_.GetOtherFileDescriptor(), STDERR_FILENO);
check_error(u"Failed to call posix_spawn_file_actions_adddup2 on stderr.");
+ error = posix_spawn_file_actions_addclose(
+ &file_actions, stdin_pipe_.GetSelfFileDescriptor());
+ check_error(u"Failed to call posix_spawn_file_actions_addclose on stdin.");
+ error = posix_spawn_file_actions_addclose(
+ &file_actions, stdout_pipe_.GetSelfFileDescriptor());
+ check_error(u"Failed to call posix_spawn_file_actions_addclose on stdout.");
+ error = posix_spawn_file_actions_addclose(
+ &file_actions, stderr_pipe_.GetSelfFileDescriptor());
+ check_error(u"Failed to call posix_spawn_file_actions_addclose on stderr.");
posix_spawnattr_t attr;
error = posix_spawnattr_init(&attr);
@@ -131,6 +140,13 @@ void PosixSpawnSubProcess::PlatformCreateProcess() {
error = posix_spawnp(&pid_, exe.c_str(), &file_actions, &attr, argv, envp);
check_error(u"Failed to call posix_spawnp.");
+
+ error = ::close(stdin_pipe_.GetOtherFileDescriptor());
+ check_error(u"Failed to close stdin.");
+ error = ::close(stdout_pipe_.GetOtherFileDescriptor());
+ check_error(u"Failed to close stdout.");
+ error = ::close(stderr_pipe_.GetOtherFileDescriptor());
+ check_error(u"Failed to close stderr.");
}
SubProcessExitResult PosixSpawnSubProcess::PlatformWaitForProcess() {