Bug 602140: Make child processes created via nsIProcess inherit the parent environment on Mac OS X. r=bsmedberg a=blocking-b7
authorJosh Aas <joshmoz@gmail.com>
Wed, 06 Oct 2010 12:22:36 -0400
changeset 54956 ea0dcfd46c613a78b0e0995a0ce519033545f320
parent 54955 d2efed071e641f261745e6a13993b45a4759aa97
child 54957 d7b6ab26d39e1f7124d62a34ce6d7474d887575e
child 55220 a6fc0ac17701f34dc37eda4b3f708a39c10873b8
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg, blocking-b7
bugs602140
milestone2.0b7pre
Bug 602140: Make child processes created via nsIProcess inherit the parent environment on Mac OS X. r=bsmedberg a=blocking-b7
xpcom/threads/nsProcessCommon.cpp
--- a/xpcom/threads/nsProcessCommon.cpp
+++ b/xpcom/threads/nsProcessCommon.cpp
@@ -62,16 +62,17 @@
 
 #if defined(PROCESSMODEL_WINAPI)
 #include "prmem.h"
 #include "nsString.h"
 #include "nsLiteralString.h"
 #include "nsReadableUtils.h"
 #else
 #ifdef XP_MACOSX
+#include <crt_externs.h>
 #include <spawn.h>
 #include <sys/wait.h>
 #endif
 #include <sys/types.h>
 #include <signal.h>
 #endif
 
 #ifdef WINCE
@@ -520,17 +521,17 @@ nsProcess::RunProcess(PRBool blocking, c
     if (posix_spawnattr_setbinpref_np(&spawnattr, attr_count, pref_cpu_types, &attr_ocount) != 0 ||
         attr_ocount != attr_count) {
         posix_spawnattr_destroy(&spawnattr);
         return NS_ERROR_FAILURE;
     }
 
     // Note that the 'argv' array is already null-terminated, which 'posix_spawnp' requires.
     pid_t newPid = 0;
-    int result = posix_spawnp(&newPid, my_argv[0], NULL, &spawnattr, my_argv, NULL);
+    int result = posix_spawnp(&newPid, my_argv[0], NULL, &spawnattr, my_argv, *_NSGetEnviron());
     mPid = static_cast<PRInt32>(newPid);
 
     posix_spawnattr_destroy(&spawnattr);
 
     if (result != 0) {
         return NS_ERROR_FAILURE;
     }
 #else