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

@@ -0,0 +1,11 @@
import Foundation
extension Process {
/// Runs the process and drains the given pipe before waiting to avoid blocking on full buffers.
func runAndReadToEnd(from pipe: Pipe) throws -> Data {
try self.run()
let data = pipe.fileHandleForReading.readToEndSafely()
self.waitUntilExit()
return data
}
}