File 3543-ssh-Trap-exits-on-handshake-process.patch of Package erlang
From 7a5abf7d05671d67d96dab443ca99d6e24d0d36a Mon Sep 17 00:00:00 2001
From: Hans Nilsson <hans@erlang.org>
Date: Tue, 28 Dec 2021 14:39:37 +0100
Subject: [PATCH 3/3] ssh: Trap exits on handshake process
---
lib/ssh/src/ssh_connection_handler.erl | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index 308cc418ee..31fdf99777 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -147,9 +147,12 @@ start_connection(Role, Socket, Options, Timeout) ->
true ->
HandshakerPid =
spawn_link(fun() ->
+ process_flag(trap_exit, true),
receive
{do_handshake, Pid} ->
handshake(Pid, erlang:monitor(process,Pid), Timeout)
+ after Timeout ->
+ {error, timeout2}
end
end),
ChildPid = start_the_connection_child(HandshakerPid, Role, Socket, Options),
@@ -2525,7 +2528,10 @@ handshake(Pid, Ref, Timeout) ->
{'DOWN', _, process, Pid, {shutdown, Reason}} ->
{error, Reason};
{'DOWN', _, process, Pid, Reason} ->
- {error, Reason}
+ {error, Reason};
+ {'EXIT',_,Reason} ->
+ stop(Pid),
+ {error, {exit,Reason}}
after Timeout ->
stop(Pid),
{error, timeout}
--
2.31.1