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
3d2a9d35
Commit
3d2a9d35
authored
Nov 10, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fd_util: added function pipe_cloexec()
Same as pipe_cloexec_nonblock(), but doesn't set non-blocking mode.
parent
6975c087
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
fd_util.c
src/fd_util.c
+24
-2
fd_util.h
src/fd_util.h
+7
-0
No files found.
src/fd_util.c
View file @
3d2a9d35
...
...
@@ -140,6 +140,30 @@ creat_cloexec(const char *path_fs, int mode)
}
int
pipe_cloexec
(
int
fd
[
2
])
{
#ifdef WIN32
return
_pipe
(
event_pipe
,
512
,
_O_BINARY
);
#else
int
ret
;
#ifdef HAVE_PIPE2
ret
=
pipe2
(
fd
,
O_CLOEXEC
);
if
(
ret
>=
0
||
errno
!=
ENOSYS
)
return
ret
;
#endif
ret
=
pipe
(
fd
);
if
(
ret
>=
0
)
{
fd_set_cloexec
(
fd
[
0
],
true
);
fd_set_cloexec
(
fd
[
1
],
true
);
}
return
ret
;
#endif
}
int
pipe_cloexec_nonblock
(
int
fd
[
2
])
{
#ifdef WIN32
...
...
@@ -158,10 +182,8 @@ pipe_cloexec_nonblock(int fd[2])
fd_set_cloexec
(
fd
[
0
],
true
);
fd_set_cloexec
(
fd
[
1
],
true
);
#ifndef WIN32
fd_set_nonblock
(
fd
[
0
]);
fd_set_nonblock
(
fd
[
1
]);
#endif
}
return
ret
;
...
...
src/fd_util.h
View file @
3d2a9d35
...
...
@@ -58,6 +58,13 @@ creat_cloexec(const char *path_fs, int mode);
/**
* Wrapper for pipe(), which sets the CLOEXEC flag (atomically if
* supported by the OS).
*/
int
pipe_cloexec
(
int
fd
[
2
]);
/**
* Wrapper for pipe(), which sets the CLOEXEC flag (atomically if
* supported by the OS).
*
* On systems that supports it (everybody except for Windows), it also
* sets the NONBLOCK flag.
...
...
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