You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This fully resolves working directory thread safety issues with subprocess spawning across all platforms. For now, subprocess is adopted conditionally in order to continue building in certain environments where the Subprocess module may not be available, in which case we fall back to Foundation Process.
Closes#441
Copy file name to clipboardExpand all lines: Sources/SWBCore/ProcessExecutionCache.swift
-5Lines changed: 0 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -17,11 +17,6 @@ public final class ProcessExecutionCache: Sendable {
17
17
privateletworkingDirectory:Path?
18
18
19
19
publicinit(workingDirectory:Path?=.root){
20
-
// FIXME: Work around lack of thread-safe working directory support in Foundation (Amazon Linux 2, OpenBSD). Executing processes in the current working directory is less deterministic, but all of the clients which use this class are generally not expected to be sensitive to the working directory anyways. This workaround can be removed once we drop support for Amazon Linux 2 and/or adopt swift-subprocess and/or Foundation.Process's working directory support is made thread safe.
let result =tryawaitSubprocess.run(.path(FilePath(url.filePath.str)), arguments:.init(arguments), environment: environment.map{.custom(.init($0))}??.inherit, workingDirectory:(currentDirectoryURL?.filePath.str).map{FilePath($0)}??nil, body:{ execution, inputWriter, outputReader, errorReader in
// Direct both stdout and stderr to the same fd. Only set `closeAfterSpawningProcess` on one of the outputs so it isn't double-closed (similarly avoid using closeAfter for the same reason).
151
+
let result =tryawaitSubprocess.run(.path(FilePath(url.filePath.str)), arguments:.init(arguments), environment: environment.map{.custom(.init($0))}??.inherit, workingDirectory:(currentDirectoryURL?.filePath.str).map{FilePath($0)}??nil, output:.fileDescriptor(writeEnd, closeAfterSpawningProcess:true), error:.fileDescriptor(writeEnd, closeAfterSpawningProcess:false), body:{ execution in
0 commit comments