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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user