Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Sources/Foundation/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) }]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does _fileSystemRepresentation need to/can be applied on other platforms as well (just to be consistent)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, it doesn't have the same level of effect on other platforms but I'll add it for good measure

if let arguments = self.arguments {
command.append(contentsOf: arguments)
}
Expand Down Expand Up @@ -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.
Expand Down