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

git version control git at videolan.org
Tue Sep 16 21:59:22 CEST 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Tue Sep 16 22:01:23 2008 +0200| [a921f15e3dea1e535431a9966e6ce4fce84c1651] | 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.

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

 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 ad0143b..7a7643f 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"
@@ -2272,11 +2272,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