Skip to content

Commit ae96ee1

Browse files
committed
ssh: use new supervisor:stop/1 function for stopping system
- catch noproc exception and return ok - improve ssh_connection_SUITE:stop_listener test
1 parent 07d5b60 commit ae96ee1

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

lib/ssh/src/ssh_system_sup.erl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,12 @@ start_system(Address0, Options) ->
7272

7373
%%%----------------------------------------------------------------
7474
stop_system(SysSup) when is_pid(SysSup) ->
75-
case lists:keyfind(SysSup, 2, supervisor:which_children(sup(server))) of
76-
{{?MODULE, Id}, SysSup, _, _} -> stop_system(Id);
77-
false -> ok
78-
end;
79-
stop_system(Id) ->
80-
supervisor:terminate_child(sup(server), {?MODULE, Id}).
81-
75+
try
76+
supervisor:stop(SysSup)
77+
catch
78+
exit:noproc ->
79+
ok
80+
end.
8281

8382
%%%----------------------------------------------------------------
8483
stop_listener(SystemSup) when is_pid(SystemSup) ->

lib/ssh/test/ssh_connection_SUITE.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,6 @@ stop_listener(Config) when is_list(Config) ->
17151715
{user_dir, UserDir},
17161716
{password, "morot"},
17171717
{exec, fun ssh_exec_echo/1}]),
1718-
17191718
ConnectionRef0 = ssh_test_lib:connect(Host, Port,
17201719
[{silently_accept_hosts, true},
17211720
{user, "foo"},
@@ -1763,8 +1762,9 @@ stop_listener(Config) when is_list(Config) ->
17631762
{user_dir, UserDir}]),
17641763
ssh:close(ConnectionRef0),
17651764
ssh:close(ConnectionRef1),
1766-
ssh:stop_daemon(Pid0),
1767-
ssh:stop_daemon(Pid1);
1765+
Pid0 = Pid1,
1766+
ok = ssh:stop_daemon(Pid0),
1767+
ok = ssh:stop_daemon(Pid1);
17681768
Error ->
17691769
ssh:close(ConnectionRef0),
17701770
ssh:stop_daemon(Pid0),

0 commit comments

Comments
 (0)