fix(macos): drain subprocess pipes before wait (#1081)

Thanks @thesash.

Co-authored-by: Sash Catanzarite <sashcatanzarite@Sash-MacBook-Pro-14in-3.local>
This commit is contained in:
Peter Steinberger
2026-01-17 08:24:34 +00:00
parent 837eea4ebd
commit eef3df9fa5
5 changed files with 14 additions and 7 deletions

View File

@@ -134,6 +134,8 @@ enum RuntimeLocator {
do {
try process.run()
// Read pipe before waitUntilExit to avoid potential deadlock
let data = pipe.fileHandleForReading.readToEndSafely()
process.waitUntilExit()
let elapsedMs = Int(Date().timeIntervalSince(start) * 1000)
if elapsedMs > 500 {
@@ -149,7 +151,6 @@ enum RuntimeLocator {
bin=\(binary, privacy: .public)
""")
}
let data = pipe.fileHandleForReading.readToEndSafely()
return String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines)
} catch {
let elapsedMs = Int(Date().timeIntervalSince(start) * 1000)