diff options
| author | Matthew Sackman <matthew@rabbitmq.com> | 2010-09-10 11:12:40 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@rabbitmq.com> | 2010-09-10 11:12:40 +0100 |
| commit | 7add764519092e91c21ff1385b37878f1e57b93b (patch) | |
| tree | e47fbff95a56cc90ad6cfb2d581c45afaac856b1 /src | |
| parent | 91035d3e09d7efa2bcbe25f0ada27acebd428ed1 (diff) | |
| parent | 6e942caf7c74e7e44fe5be5b9c17be1c971e7433 (diff) | |
| download | rabbitmq-server-git-7add764519092e91c21ff1385b37878f1e57b93b.tar.gz | |
Merging bug 23212 onto default
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_multi.erl | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/rabbit_multi.erl b/src/rabbit_multi.erl index c7a5a60027..5cfd6a5ca1 100644 --- a/src/rabbit_multi.erl +++ b/src/rabbit_multi.erl @@ -310,8 +310,8 @@ kill_wait(Pid, TimeLeft, Forceful) -> is_dead(Pid) -> PidS = integer_to_list(Pid), with_os([{unix, fun () -> - Res = os:cmd("ps --no-headers --pid " ++ PidS), - Res == "" + system("kill -0 " ++ PidS + ++ " >/dev/null 2>&1") /= 0 end}, {win32, fun () -> Res = os:cmd("tasklist /nh /fi \"pid eq " ++ @@ -322,6 +322,16 @@ is_dead(Pid) -> end end}]). +% Like system(3) +system(Cmd) -> + ShCmd = "sh -c '" ++ escape_quotes(Cmd) ++ "'", + Port = erlang:open_port({spawn, ShCmd}, [exit_status,nouse_stdio]), + receive {Port, {exit_status, Status}} -> Status end. + +% Escape the quotes in a shell command so that it can be used in "sh -c 'cmd'" +escape_quotes(Cmd) -> + lists:flatten(lists:map(fun ($') -> "'\\''"; (Ch) -> Ch end, Cmd)). + call_all_nodes(Func) -> case read_pids_file() of [] -> throw(no_nodes_running); |
