#include <unistd.h>
#include <assert.h>
#include <errno.h>
+#include <fcntl.h>
#include <ust-comm.h>
* 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;
return fd;
error_connect:
+error_fcntl:
close(fd);
error:
return ret;
msg.msg_iov = iov;
msg.msg_iovlen = 1;
- ret = recvmsg(sock, &msg, 0);
+ do {
+ ret = recvmsg(sock, &msg, 0);
+ } while (ret < 0 && errno == EINTR);
if (ret < 0) {
perror("recvmsg");
}
msg.msg_control = recv_fd;
msg.msg_controllen = sizeof(recv_fd);
- if ((ret = recvmsg(sock, &msg, 0)) < 0) {
+ do {
+ ret = recvmsg(sock, &msg, 0);
+ } while (ret < 0 && errno == EINTR);
+ if (ret < 0) {
perror("recvmsg");
goto end;
}