Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
d18c1b1a
Commit
d18c1b1a
authored
Aug 03, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fd_util: add function recvmsg_cloexec()
parent
c980fc65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
fd_util.c
src/fd_util.c
+27
-0
fd_util.h
src/fd_util.h
+22
-0
No files found.
src/fd_util.c
View file @
d18c1b1a
...
@@ -246,6 +246,33 @@ accept_cloexec_nonblock(int fd, struct sockaddr *address,
...
@@ -246,6 +246,33 @@ accept_cloexec_nonblock(int fd, struct sockaddr *address,
return
ret
;
return
ret
;
}
}
#ifndef WIN32
ssize_t
recvmsg_cloexec
(
int
sockfd
,
struct
msghdr
*
msg
,
int
flags
)
{
#ifdef MSG_CMSG_CLOEXEC
flags
|=
MSG_CMSG_CLOEXEC
;
#endif
ssize_t
result
=
recvmsg
(
sockfd
,
msg
,
flags
);
if
(
result
>=
0
)
{
struct
cmsghdr
*
cmsg
=
CMSG_FIRSTHDR
(
msg
);
while
(
cmsg
!=
NULL
)
{
if
(
cmsg
->
cmsg_type
==
SCM_RIGHTS
)
{
int
fd
=
*
(
const
int
*
)
CMSG_DATA
(
cmsg
);
fd_set_cloexec
(
fd
,
true
);
}
cmsg
=
CMSG_NXTHDR
(
msg
,
cmsg
);
}
}
return
result
;
}
#endif
#ifdef HAVE_INOTIFY_INIT
#ifdef HAVE_INOTIFY_INIT
int
int
...
...
src/fd_util.h
View file @
d18c1b1a
...
@@ -39,6 +39,14 @@
...
@@ -39,6 +39,14 @@
#include <stdbool.h>
#include <stdbool.h>
#include <stddef.h>
#include <stddef.h>
#ifndef WIN32
#if !defined(_GNU_SOURCE) && (defined(HAVE_PIPE2) || defined(HAVE_ACCEPT4))
#define _GNU_SOURCE
#endif
#include <sys/types.h>
#endif
struct
sockaddr
;
struct
sockaddr
;
/**
/**
...
@@ -91,6 +99,20 @@ int
...
@@ -91,6 +99,20 @@ int
accept_cloexec_nonblock
(
int
fd
,
struct
sockaddr
*
address
,
accept_cloexec_nonblock
(
int
fd
,
struct
sockaddr
*
address
,
size_t
*
address_length_r
);
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
* Wrapper for inotify_init(), which sets the CLOEXEC flag (atomically
* if supported by the OS).
* if supported by the OS).
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment