Re: [ID 19991001.005] [_61] [PATCH] tarball fine on win32, zip isn't
[p5sagit/p5-mst-13.2.git] / win32 / win32.c
index b28b042..1d61eb7 100644 (file)
@@ -2475,6 +2475,35 @@ GIVE_UP:
     return Nullch;
 }
 
+/* The following are just place holders.
+ * Some hosts may provide and environment that the OS is
+ * not tracking, therefore, these host must provide that
+ * environment and the current directory to CreateProcess
+ */
+
+void*
+get_childenv(void)
+{
+    return NULL;
+}
+
+void
+free_childenv(void* d)
+{
+}
+
+char*
+get_childdir(void)
+{
+    return NULL;
+}
+
+void
+free_childdir(char* d)
+{
+}
+
+
 /* XXX this needs to be made more compatible with the spawnvp()
  * provided by the various RTLs.  In particular, searching for
  * *.{com,bat,cmd} files (as done by the RTLs) is unimplemented.
@@ -2494,6 +2523,8 @@ win32_spawnvp(int mode, const char *cmdname, const char *const *argv)
 #else
     dTHXo;
     DWORD ret;
+    void* env;
+    char* dir;
     STARTUPINFO StartupInfo;
     PROCESS_INFORMATION ProcessInformation;
     DWORD create = 0;
@@ -2502,6 +2533,9 @@ win32_spawnvp(int mode, const char *cmdname, const char *const *argv)
                                             ? &argv[1] : argv);
     char *fullcmd = Nullch;
 
+    env = PerlEnv_get_childenv();
+    dir = PerlEnv_get_childdir();
+
     switch(mode) {
     case P_NOWAIT:     /* asynch + remember result */
        if (w32_num_children >= MAXIMUM_WAIT_OBJECTS) {
@@ -2532,11 +2566,6 @@ win32_spawnvp(int mode, const char *cmdname, const char *const *argv)
        create |= CREATE_NEW_CONSOLE;
     }
 
-#ifndef DEBUGGING
-    StartupInfo.dwFlags |= STARTF_USESHOWWINDOW;
-    StartupInfo.wShowWindow = SW_HIDE;
-#endif
-
 RETRY:
     if (!CreateProcess(cmdname,                /* search PATH to find executable */
                       cmd,             /* executable, and its arguments */
@@ -2544,8 +2573,8 @@ RETRY:
                       NULL,            /* thread attributes */
                       TRUE,            /* inherit handles */
                       create,          /* creation flags */
-                      NULL,            /* inherit environment */
-                      NULL,            /* inherit cwd */
+                      (LPVOID)env,     /* inherit environment */
+                      dir,             /* inherit cwd */
                       &StartupInfo,
                       &ProcessInformation))
     {
@@ -2580,7 +2609,10 @@ RETRY:
     }
 
     CloseHandle(ProcessInformation.hThread);
+
 RETVAL:
+    PerlEnv_free_childenv(env);
+    PerlEnv_free_childdir(dir);
     Safefree(cmd);
     Safefree(fullcmd);
     return (int)ret;