From 37415bea39ecfcb5bb6b48eb0ff2a4f806305320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B5ivo=20Leedj=C3=A4rv?= Date: Mon, 1 Apr 2024 10:22:45 +0200 Subject: [PATCH] Fix incorrect retry when SIGINT reaches ssh Make sure that the retry loop is never activated if a SIGINT has been received. In some cases the SIGINT could have been incorrectly detected as a lost connection which would normally enable the retry loop. This can happen when the ssh process receives SIGINT as part of the process group and shuts down, which to us looks like a lost network connection. --- src/remote.ml | 3 +++ src/uitext.ml | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/remote.ml b/src/remote.ml index 1439da367..02806a06b 100644 --- a/src/remote.ml +++ b/src/remote.ml @@ -1880,6 +1880,9 @@ let buildShellConnection shell host userOpt portOpt rootName termInteract = Don't let these signals reach ssh by blocking them. + Unfortunately, a bug introduced in OpenSSH 9.6 (also present in 9.7) + breaks this workaround by unblocking SIGINT in the ssh process. + The signals could be ignored instead of being blocked because ssh does not set handlers for SIGINT and SIGQUIT if they've been ignored at startup. But this triggers an error in ssh. The interactive diff --git a/src/uitext.ml b/src/uitext.ml index cf6881964..f4e112b72 100644 --- a/src/uitext.ml +++ b/src/uitext.ml @@ -786,6 +786,9 @@ let verifyMerge title text = true end +let intrcount = ref 0 +let intrRequested () = !intrcount <> 0 + type stateItem = { mutable ri : reconItem; mutable bytesTransferred : Uutil.Filesize.t; @@ -866,7 +869,6 @@ let doTransport reconItemList numskip isSkip = in Uutil.setProgressPrinter showProgress; - let intrcount = ref 0 in let sigtermHandler _ = if !intrcount >= 3 then raise Sys.Break; Abort.all (); @@ -1702,7 +1704,7 @@ and start2 () = exit exitStatus with | Sys.Break -> terminate () - | e when noRepeat || breakRepeat e -> begin + | e when noRepeat || breakRepeat e || intrRequested () -> begin handleException e; exit Uicommon.fatalExit end