summaryrefslogtreecommitdiff
path: root/src/wayland-os.h
diff options
context:
space:
mode:
authorPekka Paalanen <ppaalanen@gmail.com>2012-03-21 16:00:23 +0200
committerPekka Paalanen <ppaalanen@gmail.com>2012-04-25 09:37:42 +0300
commit35d5053c622a2b1502b71230c7755a8005b36301 (patch)
tree7a280d1ebdeb1acb28999ff492db342248fdbdf6 /src/wayland-os.h
parent2ccaf918ab4d5185066b84d4dd6050fa76afdd9e (diff)
os: wrap recvmsg(MSG_CMSG_CLOEXEC)
Some system C libraries do not have MSG_CMSG_CLOEXEC. This flag would automatically set O_CLOEXEC flag on any received file descriptors. Provide a fallback that does it manually. If setting CLOEXEC fails, the file descriptor is closed immediately, which will lead to failures but avoid leaks. However, setting CLOEXEC is not really expected to fail occasionally. Add tests for the wrapper. The setup is copied from connection-test.c. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Diffstat (limited to 'src/wayland-os.h')
-rw-r--r--src/wayland-os.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/wayland-os.h b/src/wayland-os.h
index 456d8b0..43c317b 100644
--- a/src/wayland-os.h
+++ b/src/wayland-os.h
@@ -29,6 +29,10 @@ wl_os_socket_cloexec(int domain, int type, int protocol);
int
wl_os_dupfd_cloexec(int fd, long minfd);
+ssize_t
+wl_os_recvmsg_cloexec(int sockfd, struct msghdr *msg, int flags);
+
+
/*
* The following are for wayland-os.c and the unit tests.
* Do not use them elsewhere.
@@ -44,6 +48,10 @@ wl_os_dupfd_cloexec(int fd, long minfd);
#define F_DUPFD_CLOEXEC 1030
#endif
+#ifndef MSG_CMSG_CLOEXEC
+#define MSG_CMSG_CLOEXEC 0x40000000
+#endif
+
#endif /* __linux__ */
#endif