From 98cd8b34a766db786ca9491c6a02506f4f647d65 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 17 Sep 2024 07:46:48 -0700
Subject: [PATCH] Close the other file descriptors after redirection has taken
place
Fixes https://github.com/libsdl-org/SDL/issues/10868
---
src/process/posix/SDL_posixprocess.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/process/posix/SDL_posixprocess.c b/src/process/posix/SDL_posixprocess.c
index 47ebd2bbe9173..cc9d004a65e60 100644
--- a/src/process/posix/SDL_posixprocess.c
+++ b/src/process/posix/SDL_posixprocess.c
@@ -197,10 +197,6 @@ bool SDL_SYS_CreateProcessWithProperties(SDL_Process *process, SDL_PropertiesID
goto posix_spawn_fail_attr;
}
- if (!AddFileDescriptorCloseActions(&fa)) {
- goto posix_spawn_fail_all;
- }
-
// Background processes don't have access to the terminal
if (process->background) {
if (stdin_option == SDL_PROCESS_STDIO_INHERITED) {
@@ -347,6 +343,10 @@ bool SDL_SYS_CreateProcessWithProperties(SDL_Process *process, SDL_PropertiesID
}
}
+ if (!AddFileDescriptorCloseActions(&fa)) {
+ goto posix_spawn_fail_all;
+ }
+
// Spawn the new process
if (process->background) {
int status = -1;