diff --git a/Sources/Foundation/Process.swift b/Sources/Foundation/Process.swift index 0f32045e49..76aeed1b4c 100644 --- a/Sources/Foundation/Process.swift +++ b/Sources/Foundation/Process.swift @@ -499,7 +499,7 @@ open class Process: NSObject { } #if os(Windows) - var command: [String] = [launchPath] + var command: [String] = [try FileManager.default._fileSystemRepresentation(withPath: launchPath) { String(decodingCString: $0, as: UTF16.self) }] if let arguments = self.arguments { command.append(contentsOf: arguments) } @@ -958,9 +958,12 @@ open class Process: NSObject { // Launch var pid = pid_t() - guard _CFPosixSpawn(&pid, launchPath, fileActions, &spawnAttrs, argv, envp) == 0 else { - throw _NSErrorWithErrno(errno, reading: true, path: launchPath) - } + + try FileManager.default._fileSystemRepresentation(withPath: launchPath, { fsRep in + guard _CFPosixSpawn(&pid, fsRep, fileActions, &spawnAttrs, argv, envp) == 0 else { + throw _NSErrorWithErrno(errno, reading: true, path: launchPath) + } + }) posix_spawnattr_destroy(&spawnAttrs) // Close the write end of the input and output pipes.