diff --git a/Sources/tart/Credentials/DockerConfigCredentialsProvider.swift b/Sources/tart/Credentials/DockerConfigCredentialsProvider.swift index 7c5ba538..5f74033a 100644 --- a/Sources/tart/Credentials/DockerConfigCredentialsProvider.swift +++ b/Sources/tart/Credentials/DockerConfigCredentialsProvider.swift @@ -39,9 +39,10 @@ class DockerConfigCredentialsProvider: CredentialsProvider { inPipe.fileHandleForWriting.write("\(host)\n".data(using: .utf8)!) inPipe.fileHandleForWriting.closeFile() + let outputData = try outPipe.fileHandleForReading.readToEnd() + process.waitUntilExit() - let outputData = try outPipe.fileHandleForReading.readToEnd() if !(process.terminationReason == .exit && process.terminationStatus == 0) { if let outputData = outputData { print(String(decoding: outputData, as: UTF8.self)) diff --git a/Sources/tart/MACAddressResolver/ARPCache.swift b/Sources/tart/MACAddressResolver/ARPCache.swift index 2ce082a2..b2c983e2 100644 --- a/Sources/tart/MACAddressResolver/ARPCache.swift +++ b/Sources/tart/MACAddressResolver/ARPCache.swift @@ -52,6 +52,11 @@ struct ARPCache { process.standardInput = FileHandle.nullDevice try process.run() + + guard let arpCommandOutput = try pipe.fileHandleForReading.readToEnd() else { + throw ARPCommandYieldedInvalidOutputError(explanation: "empty output") + } + process.waitUntilExit() if !(process.terminationReason == .exit && process.terminationStatus == 0) { @@ -60,10 +65,6 @@ struct ARPCache { terminationStatus: process.terminationStatus) } - guard let arpCommandOutput = try pipe.fileHandleForReading.readToEnd() else { - throw ARPCommandYieldedInvalidOutputError(explanation: "empty output") - } - self.arpCommandOutput = arpCommandOutput }