mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-18 01:14:38 +00:00
MINOR: systemd: replace SOCK_CLOEXEC by fcntl call to FD_CLOEXEC
Since we build systemd.o for every target, we need it to be more portable. The SOCK_CLOEXEC argument from socket() is not portable and won't build on some OS like macOS X. This patch fixes the issue by replace SOCK_CLOEXEC by a fnctl set to FD_CLOEXEC.
This commit is contained in:
parent
1ceeeacbad
commit
b861dc9371
@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user