From: Daniel Beulshausen Date: Sun, 1 Jul 2001 20:08:21 +0000 (+0000) Subject: fix some popen trouble X-Git-Tag: PRE_TSRM_MERGE_PATCH~299 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8934c1eb6a31a70408cb2353b655f7963721de48;p=php fix some popen trouble --- diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index 1613ebea40..47c91d381e 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -40,6 +40,7 @@ static void tsrm_win32_ctor(tsrm_win32_globals *globals) { globals->process = NULL; globals->process_size = 0; + globals->comspec = _strdup((GetVersion()<0x80000000)?"cmd.exe":"command.com"); } static void tsrm_win32_dtor(tsrm_win32_globals *globals) @@ -47,6 +48,7 @@ static void tsrm_win32_dtor(tsrm_win32_globals *globals) if (globals->process != NULL) { free(globals->process); } + free(globals->comspec); } TSRM_API void tsrm_win32_startup(void) @@ -102,7 +104,9 @@ TSRM_API FILE* popen(const char *command, const char *type) PROCESS_INFORMATION process; SECURITY_ATTRIBUTES security; HANDLE in, out; + char *cmd; ProcessPair *proc; + TWLS_FETCH(); security.nLength = sizeof(SECURITY_ATTRIBUTES); security.bInheritHandle = TRUE; @@ -131,10 +135,12 @@ TSRM_API FILE* popen(const char *command, const char *type) startup.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); } - - if (!CreateProcess(NULL, (LPTSTR)command, &security, &security, security.bInheritHandle, NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &process)) { + cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+4); + sprintf(cmd, "%s /c %s", TWG(comspec), command); + if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &process)) { return NULL; } + free(cmd); CloseHandle(process.hThread); proc = process_get(NULL); diff --git a/TSRM/tsrm_win32.h b/TSRM/tsrm_win32.h index 08eceb644f..c26c8f9506 100644 --- a/TSRM/tsrm_win32.h +++ b/TSRM/tsrm_win32.h @@ -34,6 +34,7 @@ typedef struct { typedef struct { ProcessPair *process; int process_size; + char *comspec; } tsrm_win32_globals; #ifdef ZTS