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
c980fc65
Commit
c980fc65
authored
Aug 03, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fd_util: add function socketpair_cloexec()
parent
36782a97
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
fd_util.c
src/fd_util.c
+24
-0
fd_util.h
src/fd_util.h
+11
-0
No files found.
src/fd_util.c
View file @
c980fc65
...
@@ -174,6 +174,30 @@ pipe_cloexec_nonblock(int fd[2])
...
@@ -174,6 +174,30 @@ pipe_cloexec_nonblock(int fd[2])
#endif
#endif
}
}
#ifndef WIN32
int
socketpair_cloexec
(
int
domain
,
int
type
,
int
protocol
,
int
sv
[
2
])
{
int
ret
;
#ifdef SOCK_CLOEXEC
ret
=
socketpair
(
domain
,
type
|
SOCK_CLOEXEC
,
protocol
,
sv
);
if
(
ret
>=
0
||
errno
!=
EINVAL
)
return
ret
;
#endif
ret
=
socketpair
(
domain
,
type
,
protocol
,
sv
);
if
(
ret
>=
0
)
{
fd_set_cloexec
(
sv
[
0
],
true
);
fd_set_cloexec
(
sv
[
1
],
true
);
}
return
ret
;
}
#endif
int
int
socket_cloexec_nonblock
(
int
domain
,
int
type
,
int
protocol
)
socket_cloexec_nonblock
(
int
domain
,
int
type
,
int
protocol
)
{
{
...
...
src/fd_util.h
View file @
c980fc65
...
@@ -65,6 +65,17 @@ pipe_cloexec(int fd[2]);
...
@@ -65,6 +65,17 @@ pipe_cloexec(int fd[2]);
int
int
pipe_cloexec_nonblock
(
int
fd
[
2
]);
pipe_cloexec_nonblock
(
int
fd
[
2
]);
#ifndef WIN32
/**
* Wrapper for socketpair(), which sets the CLOEXEC flag (atomically
* if supported by the OS).
*/
int
socketpair_cloexec
(
int
domain
,
int
type
,
int
protocol
,
int
sv
[
2
]);
#endif
/**
/**
* Wrapper for socket(), which sets the CLOEXEC and the NONBLOCK flag
* Wrapper for socket(), which sets the CLOEXEC and the NONBLOCK flag
* (atomically if supported by the OS).
* (atomically 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