[vlc-devel] commit: macosx: Use fork+exec instead of posix_spawn. (Pierre d'Herbemont )

git version control git at videolan.org
Tue Sep 16 22:00:19 CEST 2008


vlc | branch: 0.9-bugfix | Pierre d'Herbemont <pdherbemont at videolan.org> | Tue Sep 16 22:01:23 2008 +0200| [c4a3752d4ae01033ad17d6af5eea8a4370d3bf1e] | committer: Pierre d'Herbemont 

macosx: Use fork+exec instead of posix_spawn.

(As pointed by Remi)

Note, this doesn't work with just exec() for some obscure reason.
(cherry picked from commit a921f15e3dea1e535431a9966e6ce4fce84c1651)

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

 modules/gui/macosx/intf.m |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 6333335..c939516 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -31,7 +31,7 @@
 #include <sys/param.h>                                    /* for MAXPATHLEN */
 #include <string.h>
 #include <vlc_keys.h>
-#include <spawn.h>
+#include <unistd.h> /* execl() */
 
 #ifdef HAVE_CONFIG_H
 #   include "config.h"
@@ -2261,11 +2261,14 @@ end:
 
     /* Relaunch now */
     const char * path = [[[NSBundle mainBundle] executablePath] UTF8String];
-    const char *spawnedArgs[2] = { path, NULL };
-    char *spawnedEnv[] = {NULL};
 
-    posix_spawn(NULL, path, NULL, NULL, spawnedArgs, spawnedEnv);
-    exit(0);
+    /* For some reason we need to fork(), not just execl(), which reports a ENOTSUP then. */
+    if(fork() != 0)
+    {
+        exit(0);
+        return;
+    }
+    execl(path, path, NULL);
 }
 
 #pragma mark -




More information about the vlc-devel mailing list