diff --git a/src/systemd.c b/src/systemd.c index fb36dd993f..64e8e45631 100644 --- a/src/systemd.c +++ b/src/systemd.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -87,12 +88,17 @@ int sd_notify(int unset_environment, const char *message) if (socket_addr.sun.sun_path[0] == '@') socket_addr.sun.sun_path[0] = 0; - fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0); + fd = socket(AF_UNIX, SOCK_DGRAM, 0); if (fd < 0) { ret = -errno; goto end; } + if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0) { + ret = -errno; + goto end; + } + if (connect(fd, &socket_addr.sa, offsetof(struct sockaddr_un, sun_path) + path_length) != 0) { ret = -errno; goto end;