File 2523-ssh-Replace-link-by-monitor-for-exit-supervision.patch of Package erlang

From e557ef7dc3b97fac48da9d30cae9020226864198 Mon Sep 17 00:00:00 2001
From: Hans Nilsson <hans@erlang.org>
Date: Wed, 9 May 2018 14:49:09 +0200
Subject: [PATCH] ssh: Replace link by monitor for exit supervision

---
 lib/ssh/src/ssh_sftp.erl | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/lib/ssh/src/ssh_sftp.erl b/lib/ssh/src/ssh_sftp.erl
index 5984713ec9..9c391abc43 100644
--- a/lib/ssh/src/ssh_sftp.erl
+++ b/lib/ssh/src/ssh_sftp.erl
@@ -171,21 +171,16 @@ start_channel(Host, Port, UserOptions) ->
 stop_channel(Pid) ->
     case is_process_alive(Pid) of
 	true ->
-	    OldValue = process_flag(trap_exit, true),
-	    link(Pid),
-	    exit(Pid, ssh_sftp_stop_channel),
-	    receive
-		{'EXIT', Pid, normal} ->
-		    ok
-	    after 5000 ->
-		    exit(Pid, kill),
-		    receive
-			{'EXIT', Pid, killed} ->
-			    ok
-		    end
-	    end,
-	    process_flag(trap_exit, OldValue),
-	    ok;
+            MonRef = erlang:monitor(process, Pid),
+            unlink(Pid),
+            exit(Pid, ssh_sftp_stop_channel),
+            receive {'DOWN',MonRef,_,_,_} -> ok
+            after
+                1000 ->
+                    exit(Pid, kill),
+                    erlang:demonitor(MonRef, [flush]),
+                    ok
+            end;
 	false ->
 	    ok
     end.
-- 
2.16.3

openSUSE Build Service is sponsored by