diff options
| author | Tim Watson <tim@rabbitmq.com> | 2012-06-05 12:45:44 +0100 |
|---|---|---|
| committer | Tim Watson <tim@rabbitmq.com> | 2012-06-05 12:45:44 +0100 |
| commit | fedee05543002b9f2d8a2ed725e3029bff19812a (patch) | |
| tree | e43ec6eeaba30862bbb838a6f575829abaad9ee5 /src | |
| parent | 98ac91d73af6149694635523539cb5adf81b4472 (diff) | |
| download | rabbitmq-server-git-fedee05543002b9f2d8a2ed725e3029bff19812a.tar.gz | |
capture and swallow all stdio during 'rabbitmqctl wait'
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_control_main.erl | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl index 294080064c..bce20e8894 100644 --- a/src/rabbit_control_main.erl +++ b/src/rabbit_control_main.erl @@ -511,8 +511,7 @@ read_pid_file(PidFile, Wait) -> % rpc:call(os, getpid, []) at this point process_up(Pid) -> with_os([{unix, fun () -> - system("ps -p " ++ Pid - ++ " >/dev/null 2>&1") =:= 0 + system("ps -p " ++ Pid) =:= 0 end}, {win32, fun () -> Res = os:cmd("tasklist /nh /fi \"pid eq " ++ @@ -532,13 +531,16 @@ with_os(Handlers) -> % 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)). + Port = erlang:open_port({spawn, Cmd}, + [exit_status,{line, 16384}, + use_stdio, stderr_to_stdout]), + exit_loop(Port). + +exit_loop(Port) -> + receive + {Port, {exit_status, Rc}} -> Rc; + {Port, _} -> exit_loop(Port) + end. format_parse_error({_Line, Mod, Err}) -> lists:flatten(Mod:format_error(Err)). |
