refactor(macos): centralize process pipe draining

This commit is contained in:
Peter Steinberger
2026-01-17 08:53:03 +00:00
parent 1002c74d9c
commit 869ef0c5ba
7 changed files with 20 additions and 24 deletions

View File

@@ -203,10 +203,7 @@ actor PortGuardian {
proc.standardOutput = pipe
proc.standardError = Pipe()
do {
try proc.run()
// Read pipe before waitUntilExit to avoid potential deadlock
let data = pipe.fileHandleForReading.readToEndSafely()
proc.waitUntilExit()
let data = try proc.runAndReadToEnd(from: pipe)
guard !data.isEmpty else { return nil }
return String(data: data, encoding: .utf8)?
.trimmingCharacters(in: .whitespacesAndNewlines)