|FORMAT_MESSAGE_IGNORE_INSERTS
|FORMAT_MESSAGE_FROM_SYSTEM, NULL,
dwErr, 0, (char *)&sMsg, 1, NULL);
+ /* strip trailing whitespace and period */
if (0 < dwLen) {
- while (0 < dwLen && isSPACE(sMsg[--dwLen]))
- ;
+ do {
+ --dwLen; /* dwLen doesn't include trailing null */
+ } while (0 < dwLen && isSPACE(sMsg[dwLen]));
if ('.' != sMsg[dwLen])
dwLen++;
- sMsg[dwLen]= '\0';
+ sMsg[dwLen] = '\0';
}
if (0 == dwLen) {
sMsg = (char*)LocalAlloc(0, 64/**sizeof(TCHAR)*/);
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.
#else
dTHXo;
DWORD ret;
+ void* env;
+ char* dir;
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation;
DWORD create = 0;
? &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) {
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 */
NULL, /* thread attributes */
TRUE, /* inherit handles */
create, /* creation flags */
- NULL, /* inherit environment */
- NULL, /* inherit cwd */
+ (LPVOID)env, /* inherit environment */
+ dir, /* inherit cwd */
&StartupInfo,
&ProcessInformation))
{
}
CloseHandle(ProcessInformation.hThread);
+
RETVAL:
+ PerlEnv_free_childenv(env);
+ PerlEnv_free_childdir(dir);
Safefree(cmd);
Safefree(fullcmd);
return (int)ret;