Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bad file descriptor crashes #97

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion Packages/Shell/Sources/ShellData/ProcessShell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
process.launchPath = executablePath
process.standardInput = nil
process.environment = environment
process.launch()
process.run()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
// Explicitly close the pipe file handle to prevent running
// out of file descriptors.
// See https://github.com/swiftlang/swift/issues/57827
try! pipe.fileHandleForReading.close()

Check failure on line 26 in Packages/Shell/Sources/ShellData/ProcessShell.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Force tries should be avoided (force_try)
process.waitUntilExit()
guard process.terminationStatus == 0 else {
throw ProcessShellError.unexpectedTerminationStatus(process.terminationStatus)
}
return String(decoding: data, as: UTF8.self)

Check warning on line 31 in Packages/Shell/Sources/ShellData/ProcessShell.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Prefer failable `String(data:encoding:)` initializer when converting `Data` to `String` (optional_data_string_conversion)
} onCancel: {
if sendableProcess.process.isRunning {
sendableProcess.process.terminate()
Expand Down
2 changes: 1 addition & 1 deletion xcconfigs/General.xcconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GENERATE_INFOPLIST_FILE = YES
CURRENT_PROJECT_VERSION = 1
MARKETING_VERSION = 0.9.0
MARKETING_VERSION = 0.10.1
DEVELOPMENT_TEAM = 566MC7D8D4
CODE_SIGN_STYLE = Automatic
CODE_SIGN_ENTITLEMENTS = Tartelet/Supporting files/Tartelet.entitlements
Expand Down
Loading