Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
a1e644f7
Commit
a1e644f7
authored
Mar 19, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use POSIX fcntl(F_DUPFD_CLOEXEC) instead of Linux dup3()
As an added bonus, we don't need to open /dev/null for nothing.
parent
8f6ca154
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
15 deletions
+8
-15
configure.ac
configure.ac
+1
-1
src/posix/filesystem.c
src/posix/filesystem.c
+7
-14
No files found.
configure.ac
View file @
a1e644f7
...
...
@@ -557,7 +557,7 @@ AC_CHECK_FUNCS(fdatasync,,
AC_FUNC_STRCOLL
dnl Check for non-standard system calls
AC_CHECK_FUNCS([accept4
dup3
pipe2 eventfd vmsplice sched_getaffinity])
AC_CHECK_FUNCS([accept4 pipe2 eventfd vmsplice sched_getaffinity])
AH_BOTTOM([#include <vlc_fixups.h>])
...
...
src/posix/filesystem.c
View file @
a1e644f7
...
...
@@ -315,22 +315,15 @@ int vlc_dup (int oldfd)
{
int
newfd
;
#ifdef HAVE_DUP3
/* Unfortunately, dup3() works like dup2(), not like plain dup(). So we
* need such contortion to find the new file descriptor while preserving
* thread safety of the file descriptor table. */
newfd
=
vlc_open
(
"/dev/null"
,
O_RDONLY
);
if
(
likely
(
newfd
!=
-
1
))
{
if
(
likely
(
dup3
(
oldfd
,
newfd
,
O_CLOEXEC
)
==
newfd
))
return
newfd
;
close
(
newfd
);
}
#ifdef F_DUPFD_CLOEXEC
newfd
=
fcntl
(
oldfd
,
F_DUPFD_CLOEXEC
);
if
(
unlikely
(
newfd
==
-
1
&&
errno
==
EINVAL
))
#endif
{
newfd
=
dup
(
oldfd
);
if
(
likely
(
newfd
!=
-
1
))
fcntl
(
newfd
,
F_SETFD
,
FD_CLOEXEC
);
}
return
newfd
;
}
...
...
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