diff options
author | Hans Nilsson <[email protected]> | 2016-05-09 15:13:14 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2016-05-09 15:13:14 +0200 |
commit | 8aedb4e5405af6b4c80a71ff579c9bcf5143ef1c (patch) | |
tree | f5a5d23e20fa134927b20df6a6021d6781e9f888 /lib/ssh | |
parent | 5c86b4f9fa77354ee20a67cd5f63c1abd4af1afb (diff) | |
download | otp-8aedb4e5405af6b4c80a71ff579c9bcf5143ef1c.tar.gz otp-8aedb4e5405af6b4c80a71ff579c9bcf5143ef1c.tar.bz2 otp-8aedb4e5405af6b4c80a71ff579c9bcf5143ef1c.zip |
ssh: monitor os:cmd to avoid hanging on baal
Diffstat (limited to 'lib/ssh')
-rw-r--r-- | lib/ssh/test/ssh_test_lib.erl | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/lib/ssh/test/ssh_test_lib.erl b/lib/ssh/test/ssh_test_lib.erl index c6541461a1..a1291146e4 100644 --- a/lib/ssh/test/ssh_test_lib.erl +++ b/lib/ssh/test/ssh_test_lib.erl @@ -655,17 +655,48 @@ sshc(Tag) -> ). ssh_type() -> - case os:find_executable("ssh") of - false -> not_found; - _ -> - case os:cmd("ssh -V") of - "OpenSSH" ++ _ -> - openSSH; - Str -> - ct:log("ssh client ~p is unknown",[Str]), - unknown - end - end. + Parent = self(), + Pid = spawn(fun() -> + Parent ! {ssh_type,self(),ssh_type1()} + end), + MonitorRef = monitor(process, Pid), + receive + {ssh_type, Pid, Result} -> + demonitor(MonitorRef), + Result; + {'DOWN', MonitorRef, process, Pid, _Info} -> + ct:log("~p:~p Process DOWN",[?MODULE,?LINE]), + not_found + after + 10000 -> + ct:log("~p:~p Timeout",[?MODULE,?LINE]), + demonitor(MonitorRef), + not_found + end. + + +ssh_type1() -> + try + case os:find_executable("ssh") of + false -> + ct:log("~p:~p Executable \"ssh\" not found",[?MODULE,?LINE]), + not_found; + _ -> + case os:cmd("ssh -V") of + "OpenSSH" ++ _ -> + openSSH; + Str -> + ct:log("ssh client ~p is unknown",[Str]), + unknown + end + end + catch + Class:Exception -> + ct:log("~p:~p Exception ~p:~p",[?MODULE,?LINE,Class,Exception]), + not_found + end. + + algo_intersection([], _) -> []; algo_intersection(_, []) -> []; |