Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
71a1c8a6
Commit
71a1c8a6
authored
Feb 07, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlc_dup: dup with close-on-exec
parent
7e45ab1b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
1 deletion
+33
-1
configure.ac
configure.ac
+1
-1
include/vlc_fs.h
include/vlc_fs.h
+2
-0
src/libvlccore.sym
src/libvlccore.sym
+1
-0
src/text/filesystem.c
src/text/filesystem.c
+29
-0
No files found.
configure.ac
View file @
71a1c8a6
...
...
@@ -530,7 +530,7 @@ AC_CHECK_FUNCS(fdatasync,,
])
dnl Check for non-standard system calls
AC_CHECK_FUNCS([accept4 eventfd fstatfs vmsplice])
AC_CHECK_FUNCS([accept4
dup3
eventfd fstatfs vmsplice])
AH_BOTTOM([#include <vlc_fixups.h>])
...
...
include/vlc_fs.h
View file @
71a1c8a6
...
...
@@ -53,4 +53,6 @@ VLC_EXPORT( int, utf8_lstat, ( const char *filename, struct stat *buf ) );
VLC_EXPORT
(
int
,
vlc_mkstemp
,
(
char
*
)
);
VLC_EXPORT
(
int
,
vlc_dup
,
(
int
)
);
#endif
src/libvlccore.sym
View file @
71a1c8a6
...
...
@@ -440,6 +440,7 @@ vlc_readdir
vlc_scandir
vlc_stat
vlc_unlink
vlc_dup
utf8_vfprintf
var_AddCallback
var_Change
...
...
src/text/filesystem.c
View file @
71a1c8a6
...
...
@@ -535,3 +535,32 @@ int vlc_mkstemp( char *template )
return
-
1
;
}
/**
* Duplicates a file descriptor. The new file descriptor has the close-on-exec
* descriptor flag set.
* @return a new file descriptor or -1
*/
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
);
}
#endif
newfd
=
dup
(
oldfd
);
#ifdef HAVE_FCNTL
if
(
likely
(
newfd
!=
-
1
))
fcntl
(
newfd
,
F_SETFD
,
FD_CLOEXEC
);
#endif
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