summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Wragg <david@rabbitmq.com>2010-09-10 08:12:03 +0100
committerDavid Wragg <david@rabbitmq.com>2010-09-10 08:12:03 +0100
commit72b027b651fb061ecc1054e09a9e767568b3f08f (patch)
tree91a0256d7fe98c56531801b89125b4c277e8cb88
parent89a4ef423df2dfd6fc7206aa8bc1e0963d63dd08 (diff)
downloadrabbitmq-server-bug23212.tar.gz
Check the exit status of kill, not its outputbug23212
-rw-r--r--src/rabbit_multi.erl13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/rabbit_multi.erl b/src/rabbit_multi.erl
index 9b6ed4b1..5cfd6a5c 100644
--- a/src/rabbit_multi.erl
+++ b/src/rabbit_multi.erl
@@ -310,7 +310,8 @@ kill_wait(Pid, TimeLeft, Forceful) ->
is_dead(Pid) ->
PidS = integer_to_list(Pid),
with_os([{unix, fun () ->
- os:cmd("kill -0 " ++ PidS) /= ""
+ system("kill -0 " ++ PidS
+ ++ " >/dev/null 2>&1") /= 0
end},
{win32, fun () ->
Res = os:cmd("tasklist /nh /fi \"pid eq " ++
@@ -321,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);