From b38222d398bbb1e6fc7b7cc5c58d1672e03678c8 Mon Sep 17 00:00:00 2001 From: Charles Hu Date: Wed, 11 Jun 2025 14:56:44 -0700 Subject: [PATCH] Fix an issue where standard error write file descriptor was incorrectly passed to fork/exec twice --- Sources/Subprocess/Platforms/Subprocess+Linux.swift | 2 +- Sources/_SubprocessCShims/process_shims.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Subprocess/Platforms/Subprocess+Linux.swift b/Sources/Subprocess/Platforms/Subprocess+Linux.swift index c03791a7..bf0d4d37 100644 --- a/Sources/Subprocess/Platforms/Subprocess+Linux.swift +++ b/Sources/Subprocess/Platforms/Subprocess+Linux.swift @@ -82,7 +82,7 @@ extension Configuration { outputWriteFileDescriptor?.platformDescriptor() ?? -1, outputReadFileDescriptor?.platformDescriptor() ?? -1, errorWriteFileDescriptor?.platformDescriptor() ?? -1, - errorWriteFileDescriptor?.platformDescriptor() ?? -1, + errorReadFileDescriptor?.platformDescriptor() ?? -1, ] let workingDirectory: String = self.workingDirectory.string diff --git a/Sources/_SubprocessCShims/process_shims.c b/Sources/_SubprocessCShims/process_shims.c index 4f0f46df..0d4b0ba9 100644 --- a/Sources/_SubprocessCShims/process_shims.c +++ b/Sources/_SubprocessCShims/process_shims.c @@ -641,8 +641,8 @@ int _subprocess_fork_exec( if (file_descriptors[3] >= 0) { rc = close(file_descriptors[3]); } - if (file_descriptors[4] >= 0) { - rc = close(file_descriptors[4]); + if (file_descriptors[5] >= 0) { + rc = close(file_descriptors[5]); } if (rc != 0) { int error = errno;