aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2018-05-17 15:58:42 +0200
committerHans Nilsson <[email protected]>2018-05-17 15:58:42 +0200
commit3abf8d89a490f57024b4f5a6c565b40dabb74a1f (patch)
tree8ecab0f6396743cb05cc44acd2124dd8e2df2086
parent9962a0e9bc96055627e75485c1cc01b3a412894b (diff)
parente557ef7dc3b97fac48da9d30cae9020226864198 (diff)
downloadotp-3abf8d89a490f57024b4f5a6c565b40dabb74a1f.tar.gz
otp-3abf8d89a490f57024b4f5a6c565b40dabb74a1f.tar.bz2
otp-3abf8d89a490f57024b4f5a6c565b40dabb74a1f.zip
Merge branch 'hans/ssh/monitor/OTP-15082'
* hans/ssh/monitor/OTP-15082: ssh: Replace link by monitor for exit supervision
-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.