]> git.sesse.net Git - vlc/commitdiff
Implement vlc_pipe()
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 9 Feb 2011 20:46:09 +0000 (22:46 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 9 Feb 2011 21:00:13 +0000 (23:00 +0200)
configure.ac
include/vlc_fs.h
src/libvlccore.sym
src/misc/filesystem.c
src/win32/filesystem.c

index 45b5242f7c9bc6565ef0b3f01d35b1c1905bb72e..e987183db31feac8ae9a39f7701033a20718acbf 100644 (file)
@@ -557,7 +557,7 @@ AC_CHECK_FUNCS(fdatasync,,
 AC_FUNC_STRCOLL
 
 dnl Check for non-standard system calls
-AC_CHECK_FUNCS([accept4 dup3 eventfd vmsplice sched_getaffinity])
+AC_CHECK_FUNCS([accept4 dup3 pipe2 eventfd vmsplice sched_getaffinity])
 
 AH_BOTTOM([#include <vlc_fixups.h>])
 
index 56d2f57d32eddfa4c7c085a37aa309c1b4740410..da6d28e2800fd2477772c8270f87e1def661c210 100644 (file)
@@ -73,4 +73,5 @@ VLC_EXPORT( int, vlc_lstat, ( const char *filename, struct stat *buf ) );
 VLC_EXPORT( int, vlc_mkstemp, ( char * ) );
 
 VLC_EXPORT( int, vlc_dup, ( int ) );
+VLC_EXPORT( int, vlc_pipe, ( int[2] ) );
 #endif
index a59f8af052feee4726337399a93d04dae8ae7fd7..bd4a08754bda6934b0c85c44e7b99f5c94573cf4 100644 (file)
@@ -467,6 +467,7 @@ vlc_strcasestr
 vlc_unlink
 vlc_rename
 vlc_dup
+vlc_pipe
 vlc_accept
 utf8_vfprintf
 var_AddCallback
index 9138ae906f88a9a98e6cedad8ca4952c99f2c310..80576e1c847cbe6eb8f0316eb058b2bd09fa4cd5 100644 (file)
@@ -334,6 +334,26 @@ int vlc_dup (int oldfd)
     return newfd;
 }
 
+/**
+ * Creates a pipe (see "man pipe" for further reference).
+ */
+int vlc_pipe (int fds[2])
+{
+#ifdef HAVE_PIPE2
+    if (pipe2 (fds, O_CLOEXEC) == 0)
+        return 0;
+    if (errno != ENOSYS)
+        return -1;
+#endif
+
+    if (pipe (fds))
+        return -1;
+
+    fcntl (fds[0], F_SETFD, FD_CLOEXEC);
+    fcntl (fds[1], F_SETFD, FD_CLOEXEC);
+    return 0;
+}
+
 #include <vlc_network.h>
 
 /**
index 62c0b1eaf1cd68c43d8853f18a8ae0b5e68e82b3..e236186b5407e7e1468dad08655b829e5a0064ac 100644 (file)
@@ -255,6 +255,11 @@ int vlc_dup (int oldfd)
 #endif
 }
 
+int vlc_pipe (int fds[2])
+{
+    return _pipe (fds, 32768, O_BINARY);
+}
+
 #include <vlc_network.h>
 
 int vlc_socket (int pf, int type, int proto, bool nonblock)