From d18c1b1a0ab57d77ba823cfedf40077d24dafbd7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 3 Aug 2010 15:55:25 +0200 Subject: fd_util: add function recvmsg_cloexec() --- src/fd_util.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/fd_util.h') diff --git a/src/fd_util.h b/src/fd_util.h index b49a51373..80fb98703 100644 --- a/src/fd_util.h +++ b/src/fd_util.h @@ -39,6 +39,14 @@ #include #include +#ifndef WIN32 +#if !defined(_GNU_SOURCE) && (defined(HAVE_PIPE2) || defined(HAVE_ACCEPT4)) +#define _GNU_SOURCE +#endif + +#include +#endif + struct sockaddr; /** @@ -91,6 +99,20 @@ int accept_cloexec_nonblock(int fd, struct sockaddr *address, size_t *address_length_r); + +#ifndef WIN32 + +struct msghdr; + +/** + * Wrapper for recvmsg(), which sets the CLOEXEC flag (atomically if + * supported by the OS). + */ +ssize_t +recvmsg_cloexec(int sockfd, struct msghdr *msg, int flags); + +#endif + /** * Wrapper for inotify_init(), which sets the CLOEXEC flag (atomically * if supported by the OS). -- cgit v1.2.3