aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2018-05-09 14:49:09 +0200
committerHans Nilsson <[email protected]>2018-05-16 15:34:28 +0200
commite557ef7dc3b97fac48da9d30cae9020226864198 (patch)
tree427dcea7a4c24f6c6aed655b20b4830f5f1507fe /lib
parent84e655feccb4780b8db17a42549b35ded03baf1a (diff)
downloadotp-e557ef7dc3b97fac48da9d30cae9020226864198.tar.gz
otp-e557ef7dc3b97fac48da9d30cae9020226864198.tar.bz2
otp-e557ef7dc3b97fac48da9d30cae9020226864198.zip
ssh: Replace link by monitor for exit supervision
Diffstat (limited to 'lib')
-rw-r--r--lib/ssh/src/ssh_sftp.erl25
1 files 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.