summaryrefslogtreecommitdiff
path: root/src/sd_notify.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/sd_notify.erl')
-rw-r--r--src/sd_notify.erl5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/sd_notify.erl b/src/sd_notify.erl
index 0880e48..a31b5b6 100644
--- a/src/sd_notify.erl
+++ b/src/sd_notify.erl
@@ -43,7 +43,7 @@ sd_notifyf(UnsetEnv, Format, Data) ->
sd_pid_notifyf(Pid, UnsetEnv, Format, Data) ->
sd_pid_notify_with_fds(Pid, UnsetEnv, lists:flatten(io_lib:format(Format, Data)), []).
-sd_pid_notify_with_fds(_Pid, _UnsetEnv, Call, _Fds) ->
+sd_pid_notify_with_fds(_Pid, UnsetEnv, Call, _Fds) ->
error_logger:info_msg("systemd: ~p", [Call]),
case os:getenv("NOTIFY_SOCKET") of
false -> {error, not_configured};
@@ -54,6 +54,9 @@ sd_pid_notify_with_fds(_Pid, _UnsetEnv, Call, _Fds) ->
{ok, Socket} ->
Result = gen_udp:send(Socket, {local,Path}, 0, Call),
gen_udp:close(Socket),
+
+ UnsetEnv == true andalso os:unsetenv("NOTIFY_SOCKET"),
+
Result
end
end.