Skip to content

Commit 4d785c5

Browse files
committed
Fix bad file descriptor crashes
Explicitly close the pipe file handle after the data has been read.
1 parent d69f366 commit 4d785c5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Packages/Shell/Sources/ShellData/ProcessShell.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ public struct ProcessShell: Shell {
1818
process.launchPath = executablePath
1919
process.standardInput = nil
2020
process.environment = environment
21-
process.launch()
21+
process.run()
2222
let data = pipe.fileHandleForReading.readDataToEndOfFile()
23+
// Explicitly close the pipe file handle to prevent running
24+
// out of file descriptors.
25+
// See https://github.com/swiftlang/swift/issues/57827
26+
try! pipe.fileHandleForReading.close()
2327
process.waitUntilExit()
2428
guard process.terminationStatus == 0 else {
2529
throw ProcessShellError.unexpectedTerminationStatus(process.terminationStatus)

xcconfigs/General.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GENERATE_INFOPLIST_FILE = YES
22
CURRENT_PROJECT_VERSION = 1
3-
MARKETING_VERSION = 0.9.0
3+
MARKETING_VERSION = 0.10.1
44
DEVELOPMENT_TEAM = 566MC7D8D4
55
CODE_SIGN_STYLE = Automatic
66
CODE_SIGN_ENTITLEMENTS = Tartelet/Supporting files/Tartelet.entitlements

0 commit comments

Comments
 (0)