Skip to content

Commit 06bd59d

Browse files
authored
Use FSR for Process executable path on Windows (#4999)
* Use FSR for Process executable path on Windows * Use FSR on Linux as well
1 parent 9118940 commit 06bd59d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Sources/Foundation/Process.swift

+7-4
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ open class Process: NSObject {
499499
}
500500

501501
#if os(Windows)
502-
var command: [String] = [launchPath]
502+
var command: [String] = [try FileManager.default._fileSystemRepresentation(withPath: launchPath) { String(decodingCString: $0, as: UTF16.self) }]
503503
if let arguments = self.arguments {
504504
command.append(contentsOf: arguments)
505505
}
@@ -958,9 +958,12 @@ open class Process: NSObject {
958958

959959
// Launch
960960
var pid = pid_t()
961-
guard _CFPosixSpawn(&pid, launchPath, fileActions, &spawnAttrs, argv, envp) == 0 else {
962-
throw _NSErrorWithErrno(errno, reading: true, path: launchPath)
963-
}
961+
962+
try FileManager.default._fileSystemRepresentation(withPath: launchPath, { fsRep in
963+
guard _CFPosixSpawn(&pid, fsRep, fileActions, &spawnAttrs, argv, envp) == 0 else {
964+
throw _NSErrorWithErrno(errno, reading: true, path: launchPath)
965+
}
966+
})
964967
posix_spawnattr_destroy(&spawnAttrs)
965968

966969
// Close the write end of the input and output pipes.

0 commit comments

Comments
 (0)