diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-07-31 17:06:51 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-07-31 17:06:51 +0100 |
commit | 5d75c6e30b01b0129cca3c43775a7706565a061d (patch) | |
tree | f5d85a4539a807b161cc06c635d7b95d368186b6 | |
parent | 2c32f6cdb2c84d1324645423f132214ebf4f1031 (diff) | |
download | rabbitmq-server-5d75c6e30b01b0129cca3c43775a7706565a061d.tar.gz |
Integrate win32_cmd/1 into rabbit_misc:os_cmd/1, so that we have just one function we can always use instead of os:cmd/1.
-rw-r--r-- | src/rabbit_control_main.erl | 2 | ||||
-rw-r--r-- | src/rabbit_disk_monitor.erl | 3 | ||||
-rw-r--r-- | src/rabbit_misc.erl | 21 |
3 files changed, 14 insertions, 12 deletions
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl index 4be77f82..c57c9f4a 100644 --- a/src/rabbit_control_main.erl +++ b/src/rabbit_control_main.erl @@ -603,7 +603,7 @@ process_up(Pid) -> end}, {win32, fun () -> Cmd = "tasklist /nh /fi \"pid eq " ++ Pid ++ "\" ", - Res = os:cmd(rabbit_misc:win32_cmd(Cmd ++ "2>&1")), + Res = rabbit_misc:os_cmd(Cmd ++ "2>&1"), case re:run(Res, "erl\\.exe", [{capture, none}]) of match -> true; _ -> false diff --git a/src/rabbit_disk_monitor.erl b/src/rabbit_disk_monitor.erl index 227bbcee..9b7bafd5 100644 --- a/src/rabbit_disk_monitor.erl +++ b/src/rabbit_disk_monitor.erl @@ -168,8 +168,7 @@ get_disk_free(Dir, {unix, Sun}) get_disk_free(Dir, {unix, _}) -> parse_free_unix(rabbit_misc:os_cmd("/bin/df -kP " ++ Dir)); get_disk_free(Dir, {win32, _}) -> - Cmd = "dir /-C /W \"" ++ Dir ++ [$"], - parse_free_win32(os:cmd(rabbit_misc:win32_cmd(Cmd))); + parse_free_win32(rabbit_misc:os_cmd("dir /-C /W \"" ++ Dir ++ [$"])); get_disk_free(_, Platform) -> {unknown, Platform}. diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 672d3b40..ce7d73c7 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -60,7 +60,6 @@ -export([append_rpc_all_nodes/4]). -export([multi_call/2]). -export([os_cmd/1]). --export([win32_cmd/1]). -export([gb_sets_difference/2]). -export([version/0, which_applications/0]). -export([sequence_error/1]). @@ -231,7 +230,6 @@ -spec(multi_call/2 :: ([pid()], any()) -> {[{pid(), any()}], [{pid(), any()}]}). -spec(os_cmd/1 :: (string()) -> string()). --spec(win32_cmd/1 :: (string()) -> string()). -spec(gb_sets_difference/2 :: (gb_set(), gb_set()) -> gb_set()). -spec(version/0 :: () -> string()). -spec(which_applications/0 :: () -> [{atom(), string(), string()}]). @@ -975,15 +973,20 @@ receive_multi_call([{Mref, Pid} | MonitorPids], Good, Bad) -> end. os_cmd(Command) -> - Exec = hd(string:tokens(Command, " ")), - case os:find_executable(Exec) of - false -> throw({command_not_found, Exec}); - _ -> os:cmd(Command) + case os:type() of + {win32, _} -> + %% Clink workaround; see + %% http://code.google.com/p/clink/issues/detail?id=141 + os:cmd(" " + Command); + _ -> + %% Don't just return "/bin/sh: <cmd>: not found" if not found + Exec = hd(string:tokens(Command, " ")), + case os:find_executable(Exec) of + false -> throw({command_not_found, Exec}); + _ -> os:cmd(Command) + end end. -%% Clink workaround: http://code.google.com/p/clink/issues/detail?id=141 -win32_cmd(Command) -> " " ++ Command. - gb_sets_difference(S1, S2) -> gb_sets:fold(fun gb_sets:delete_any/2, S1, S2). |