Skip to content

Commit

Permalink
Fix incorrect retry when SIGINT reaches ssh
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tleedjarv committed Apr 1, 2024
1 parent 9779470 commit 37415be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/remote.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/uitext.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 ();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 37415be

Please sign in to comment.