summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Lebedeff <alebedev@mirantis.com>2016-03-11 20:17:08 +0300
committerAlexey Lebedeff <alebedev@mirantis.com>2016-03-11 20:17:08 +0300
commitdf0965b4a69f8191bba7d213d82ef2edf0d09b77 (patch)
treee3624f233de952f440ab7162400d74c29a5104e5
parent9b6c04b11d879601c8aa11c5ae0e4749618884be (diff)
downloadrabbitmq-server-git-df0965b4a69f8191bba7d213d82ef2edf0d09b77.tar.gz
Explicitly close `socat` port
Before that it happened implicitly due to the death of the controlling process. But it's better to make it explicit.
-rw-r--r--src/rabbit.erl15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 1dca053d8c..d3e0dcc632 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -340,17 +340,22 @@ sd_notify_socat() ->
false
end.
+sd_open_port() ->
+ open_port(
+ {spawn_executable, os:find_executable("socat")},
+ [{args, ["unix-sendto:" ++ os:getenv("NOTIFY_SOCKET"), "STDIO"]},
+ use_stdio, out]).
+
sd_notify_socat(Unit) ->
- case catch open_port(
- {spawn_executable, os:find_executable("socat")},
- [{args, ["unix-sendto:" ++ os:getenv("NOTIFY_SOCKET"), "STDIO"]},
- exit_status, use_stdio, out]) of
+ case sd_open_port() of
{'EXIT', Exit} ->
io:format(standard_error, "Failed to start socat ~p~n", [Exit]),
false;
Port ->
Port ! {self(), {command, sd_notify_data()}},
- sd_wait_activation(Port, Unit)
+ Result = sd_wait_activation(Port, Unit),
+ port_close(Port),
+ Result
end.
sd_current_unit() ->