refactor(macos): centralize process pipe draining
This commit is contained in:
11
apps/macos/Sources/Clawdbot/Process+PipeRead.swift
Normal file
11
apps/macos/Sources/Clawdbot/Process+PipeRead.swift
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user