mirror of
https://github.com/cirruslabs/tart.git
synced 2026-09-30 03:01:12 +02:00
Preserve stdout when running Softnet without a control FD (#1329)
This commit is contained in:
@@ -11,14 +11,13 @@ enum SoftnetError: Error {
|
||||
|
||||
class Softnet: Network {
|
||||
private let process = Process()
|
||||
private var controlFileHandle: FileHandle?
|
||||
private var monitorTask: Task<Void, Error>? = nil
|
||||
private let monitorTaskFinished = ManagedAtomic<Bool>(false)
|
||||
|
||||
let vmFD: Int32
|
||||
|
||||
init(vmMACAddress: String, extraArguments: [String] = [], controlFD: Int32? = nil) throws {
|
||||
var controlFileHandle: FileHandle?
|
||||
|
||||
if let controlFD = controlFD {
|
||||
guard controlFD > STDERR_FILENO else {
|
||||
throw SoftnetError.InitializationFailed(why: "Softnet control file descriptor must be greater than 2")
|
||||
@@ -95,7 +94,7 @@ class Softnet: Network {
|
||||
}
|
||||
|
||||
func run(_ sema: AsyncSemaphore) throws {
|
||||
defer { try? (process.standardOutput as? FileHandle)?.close() }
|
||||
defer { try? controlFileHandle?.close() }
|
||||
|
||||
try process.run()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user