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
a13897cf
Commit
a13897cf
authored
Sep 13, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system/FileDescriptor: add CheckDuplicate()
parent
b188ae0e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
FileDescriptor.cxx
src/system/FileDescriptor.cxx
+10
-0
FileDescriptor.hxx
src/system/FileDescriptor.hxx
+8
-0
No files found.
src/system/FileDescriptor.cxx
View file @
a13897cf
...
...
@@ -188,6 +188,16 @@ FileDescriptor::DisableCloseOnExec() noexcept
fcntl
(
fd
,
F_SETFD
,
old_flags
&
~
FD_CLOEXEC
);
}
bool
FileDescriptor
::
CheckDuplicate
(
int
new_fd
)
noexcept
{
if
(
fd
==
new_fd
)
{
DisableCloseOnExec
();
return
true
;
}
else
return
Duplicate
(
new_fd
);
}
#endif
#ifdef USE_EVENTFD
...
...
src/system/FileDescriptor.hxx
View file @
a13897cf
...
...
@@ -146,6 +146,14 @@ public:
bool
Duplicate
(
int
new_fd
)
const
noexcept
{
return
::
dup2
(
Get
(),
new_fd
)
==
0
;
}
/**
* Similar to Duplicate(), but if destination and source file
* descriptor are equal, clear the close-on-exec flag. Use
* this method to inject file descriptors into a new child
* process, to be used by a newly executed program.
*/
bool
CheckDuplicate
(
int
new_fd
)
noexcept
;
#endif
#ifdef USE_EVENTFD
...
...
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