diff options
author | Matthias Radestock <matthias@lshift.net> | 2009-03-26 16:27:22 +0000 |
---|---|---|
committer | Matthias Radestock <matthias@lshift.net> | 2009-03-26 16:27:22 +0000 |
commit | 88b781d8ce4f07dbc357461beff5fef7b5e30151 (patch) | |
tree | a532d6d7909da8e11246dd20f9a731bcd0c7f66b | |
parent | 33c9f78cdba8e12e615d0a2552650317795d2fbf (diff) | |
download | rabbitmq-server-bug20518.tar.gz |
on windows, write to stdout in stderr to avoid bufferingbug20518
-rw-r--r-- | src/rabbit_misc.erl | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 5730fdc0..b15ad68e 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -372,6 +372,16 @@ ensure_parent_dirs_exist(Filename) -> end. format_stderr(Fmt, Args) -> - Port = open_port({fd, 0, 2}, [out]), - port_command(Port, io_lib:format(Fmt, Args)), - port_close(Port). + case os:type() of + {unix, _} -> + Port = open_port({fd, 0, 2}, [out]), + port_command(Port, io_lib:format(Fmt, Args)), + port_close(Port); + {win32, _} -> + %% stderr on Windows is buffered and I can't figure out a + %% way to trigger a fflush(stderr) in Erlang. So rather + %% than risk losing output we write to stdout instead, + %% which appears to be unbuffered. + io:format(Fmt, Args) + end, + ok. |