rbb 99/12/14 17:15:31
Modified: src/lib/apr/threadproc/win32 proc.c Log: Fix process creation on Windows. We need to pretty much always provide absolute paths instead of relative paths when we want to specify a new directory. Submitted by: Allan Edwards Reviewed by: Ryan Bloom Revision Changes Path 1.13 +47 -3 apache-2.0/src/lib/apr/threadproc/win32/proc.c Index: proc.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/threadproc/win32/proc.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- proc.c 1999/11/01 20:02:37 1.12 +++ proc.c 1999/12/15 01:15:30 1.13 @@ -151,7 +151,21 @@ ap_status_t ap_setprocattr_dir(struct procattr_t *attr, const char *dir) { - attr->currdir = ap_pstrdup(attr->cntxt, dir); + char path[MAX_PATH]; + int length; + + if (dir[0] != '\\' && dir[1] != ':') { + length = GetCurrentDirectory(MAX_PATH, path); + + if (length == 0 || length + strlen(dir) + 1 >= MAX_PATH) + return APR_ENOMEM; + + attr->currdir = ap_pstrcat(attr->cntxt, path, "\\", dir, NULL); + } + else { + attr->currdir = ap_pstrdup(attr->cntxt, dir); + } + if (attr->currdir) { return APR_SUCCESS; } @@ -212,9 +226,39 @@ if (attr->child_err) { attr->si.hStdError = attr->child_err->filehand; } + } + + if (attr->cmdtype == APR_PROGRAM) { + if (attr->currdir == NULL) { + cmdline = ap_pstrdup(cont, progname); + } + else { + cmdline = ap_pstrcat(cont, attr->currdir, "\\", progname, NULL); + } } - cmdline = ap_pstrdup(cont, progname); - i = 0; + else { + char * shell_cmd; + OSVERSIONINFO osver; + osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + + /* + * Use CMD.EXE for NT, COMMAND.COM for WIN95 + */ + if (GetVersionEx(&osver)) { + if (osver.dwPlatformId != VER_PLATFORM_WIN32_NT) { + shell_cmd = ap_pstrdup(cont, "COMMAND.COM /C "); + } + else { + shell_cmd = ap_pstrdup(cont, "CMD.EXE /C "); + } + } + else { + shell_cmd = ap_pstrdup(cont, "CMD.EXE /C "); + } + cmdline = ap_pstrcat(cont, shell_cmd, progname, NULL); + } + + i = 1; while (args && args[i]) { cmdline = ap_pstrcat(cont, cmdline, " ", args[i], NULL); i++;