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
+4 -1
View File
@@ -17,8 +17,11 @@ enum Launchctl {
process.standardError = pipe
do {
try process.run()
process.waitUntilExit()
// Read pipe output BEFORE waitUntilExit to avoid deadlock.
// If the process writes enough to fill the pipe buffer (~64KB),
// it will block until someone reads. Reading first prevents this.
let data = pipe.fileHandleForReading.readToEndSafely()
process.waitUntilExit()
let output = String(data: data, encoding: .utf8) ?? ""
return Result(status: process.terminationStatus, output: output)
} catch {