diff options
author | Hans Nilsson <[email protected]> | 2018-05-09 14:49:09 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2018-05-16 15:34:28 +0200 |
commit | e557ef7dc3b97fac48da9d30cae9020226864198 (patch) | |
tree | 427dcea7a4c24f6c6aed655b20b4830f5f1507fe /lib | |
parent | 84e655feccb4780b8db17a42549b35ded03baf1a (diff) | |
download | otp-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.erl | 25 |
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. |