[vlc-devel] commit: decomp: use plain fork/exec if POSIX spawn is missing ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Dec 21 14:36:37 CET 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Dec 21 15:35:55 2008 +0200| [25bdf84ce207fd13191b490b62bb58be05ce7b2d] | committer: Rémi Denis-Courmont 

decomp: use plain fork/exec if POSIX spawn is missing

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=25bdf84ce207fd13191b490b62bb58be05ce7b2d
---

 modules/stream_filter/decomp.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/modules/stream_filter/decomp.c b/modules/stream_filter/decomp.c
index f083fc7..da86731 100644
--- a/modules/stream_filter/decomp.c
+++ b/modules/stream_filter/decomp.c
@@ -27,6 +27,9 @@
 #include <vlc_stream.h>
 #include <vlc_network.h>
 #include <unistd.h>
+#ifndef _POSIX_SPAWN
+# define _POSIX_SPAWN (-1)
+#endif
 #include <fcntl.h>
 #include <spawn.h>
 #include <sys/wait.h>
@@ -268,6 +271,7 @@ static int Open (stream_t *stream, const char *path)
             cloexec (uncomp[0]);
             p_sys->read_fd = uncomp[0];
 
+#if (_POSIX_SPAWN >= 0)
             posix_spawn_file_actions_t actions;
             if (posix_spawn_file_actions_init (&actions) == 0)
             {
@@ -291,6 +295,25 @@ static int Open (stream_t *stream, const char *path)
                 }
                 posix_spawn_file_actions_destroy (&actions);
             }
+#else /* _POSIX_SPAWN */
+            switch (p_sys->pid = fork ())
+            {
+                case -1:
+                    msg_Err (stream, "Cannot fork (%m)");
+                    break;
+                case 0:
+                    dup2 (comp[0], 0);
+                    close (comp[0]);
+                    dup2 (uncomp[1], 1);
+                    close (uncomp[1]);
+                    execlp (path, path, (char *)NULL);
+                    exit (1); /* if we get, execlp() failed! */
+                default:
+                    if (vlc_clone (&p_sys->thread, Thread, stream,
+                                   VLC_THREAD_PRIORITY_INPUT) == 0)
+                        ret = VLC_SUCCESS;
+            }
+#endif /* _POSIX_SPAWN < 0 */
             close (uncomp[1]);
             if (ret != VLC_SUCCESS)
                 close (uncomp[0]);




More information about the vlc-devel mailing list