@@ -40,13 +40,15 @@ static void tsrm_win32_ctor(tsrm_win32_globals *globals)
40
40
{
41
41
globals -> process = NULL ;
42
42
globals -> process_size = 0 ;
43
+ globals -> comspec = _strdup ((GetVersion ()< 0x80000000 )?"cmd.exe" :"command.com" );
43
44
}
44
45
45
46
static void tsrm_win32_dtor (tsrm_win32_globals * globals )
46
47
{
47
48
if (globals -> process != NULL ) {
48
49
free (globals -> process );
49
50
}
51
+ free (globals -> comspec );
50
52
}
51
53
52
54
TSRM_API void tsrm_win32_startup (void )
@@ -102,7 +104,9 @@ TSRM_API FILE* popen(const char *command, const char *type)
102
104
PROCESS_INFORMATION process ;
103
105
SECURITY_ATTRIBUTES security ;
104
106
HANDLE in , out ;
107
+ char * cmd ;
105
108
ProcessPair * proc ;
109
+ TWLS_FETCH ();
106
110
107
111
security .nLength = sizeof (SECURITY_ATTRIBUTES );
108
112
security .bInheritHandle = TRUE;
@@ -131,10 +135,12 @@ TSRM_API FILE* popen(const char *command, const char *type)
131
135
startup .hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE );
132
136
}
133
137
134
-
135
- if (!CreateProcess (NULL , (LPTSTR )command , & security , & security , security .bInheritHandle , NORMAL_PRIORITY_CLASS , NULL , NULL , & startup , & process )) {
138
+ cmd = (char * )malloc (strlen (command )+ strlen (TWG (comspec ))+ 4 );
139
+ sprintf (cmd , "%s /c %s" , TWG (comspec ), command );
140
+ if (!CreateProcess (NULL , cmd , & security , & security , security .bInheritHandle , NORMAL_PRIORITY_CLASS , NULL , NULL , & startup , & process )) {
136
141
return NULL ;
137
142
}
143
+ free (cmd );
138
144
139
145
CloseHandle (process .hThread );
140
146
proc = process_get (NULL );
0 commit comments