X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=liblttng-ust-comm%2Flttng-ust-comm.c;h=9baa4dc50d3a3a48fb429c1ce4e7026e5a1f5ae5;hb=49365f4b706194cafe75d8b759554bf9de743c1d;hp=21f48ed00bf00cfa10351df04950817bb968ea25;hpb=7e3cfcbe9ccfef8837c42efcf5332035814415fc;p=lttng-ust.git diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c index 21f48ed0..9baa4dc5 100644 --- a/liblttng-ust-comm/lttng-ust-comm.c +++ b/liblttng-ust-comm/lttng-ust-comm.c @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -119,12 +120,17 @@ int ustcomm_connect_unix_sock(const char *pathname) * libust threads require the close-on-exec flag for all * resources so it does not leak file descriptors upon exec. */ - fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); + fd = socket(PF_UNIX, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); ret = fd; goto error; } + ret = fcntl(fd, F_SETFD, FD_CLOEXEC); + if (ret < 0) { + perror("fcntl"); + goto error_fcntl; + } memset(&sun, 0, sizeof(sun)); sun.sun_family = AF_UNIX; @@ -144,6 +150,7 @@ int ustcomm_connect_unix_sock(const char *pathname) return fd; error_connect: +error_fcntl: close(fd); error: return ret;