From 0e4b28ac25adb8d1d40bc54708e6af2e5e4c4ed5 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 8 Dec 2025 22:53:40 +0100 Subject: [PATCH] macos: fail fast when SSH tunnel exits --- apps/macos/Sources/Clawdis/ControlChannel.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/macos/Sources/Clawdis/ControlChannel.swift b/apps/macos/Sources/Clawdis/ControlChannel.swift index f538c4feb..e33928647 100644 --- a/apps/macos/Sources/Clawdis/ControlChannel.swift +++ b/apps/macos/Sources/Clawdis/ControlChannel.swift @@ -267,9 +267,17 @@ final class ControlChannel: ObservableObject { } proc.arguments = args proc.standardInput = nil - proc.standardOutput = Pipe() - proc.standardError = Pipe() + let outPipe = Pipe() + let errPipe = Pipe() + proc.standardOutput = outPipe + proc.standardError = errPipe try proc.run() + // Give ssh a brief moment; if it exits immediately, surface the error. + try? Task.sleep(nanoseconds: 200_000_000) // 200ms + if !proc.isRunning { + let err = String(data: errPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines) + throw ControlChannelError.sshFailed(err ?? "ssh exited") + } self.sshProcess = proc return localPort }