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

@@ -279,6 +279,8 @@ enum GatewayEnvironment {
process.standardError = pipe
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 {
@@ -294,7 +296,6 @@ enum GatewayEnvironment {
bin=\(binary, privacy: .public)
""")
}
let data = pipe.fileHandleForReading.readToEndSafely()
let raw = String(data: data, encoding: .utf8)?
.trimmingCharacters(in: .whitespacesAndNewlines)
return Semver.parse(raw)