summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Beulshausen <dbeu@php.net>2001-07-01 20:08:21 +0000
committerDaniel Beulshausen <dbeu@php.net>2001-07-01 20:08:21 +0000
commit8934c1eb6a31a70408cb2353b655f7963721de48 (patch)
treeb5ca3a056396411000cdc6b47a1657b362794b1c
parent512f6af726832d260b96dd35d946e0bdce775408 (diff)
downloadphp-git-8934c1eb6a31a70408cb2353b655f7963721de48.tar.gz
fix some popen trouble
-rw-r--r--TSRM/tsrm_win32.c10
-rw-r--r--TSRM/tsrm_win32.h1
2 files changed, 9 insertions, 2 deletions
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