- _popen/_wpopen: When overriding the default standard input/output handles, don...
[reactos.git] / reactos / lib / sdk / crt / stdio / popen.c
index 199c3d9..a962479 100644 (file)
@@ -77,14 +77,19 @@ FILE *_tpopen (const _TCHAR *cm, const _TCHAR *md) /* program name, pipe mode */
   StartupInfo.cb = sizeof(STARTUPINFO);
 
   if (*md == 'r' ) {
+    StartupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
        StartupInfo.hStdOutput = hWritePipe;
        StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
   }
   else if ( *md == 'w' ) {
        StartupInfo.hStdInput = hReadPipe;
+    StartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
        StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
   }
 
+  if (StartupInfo.dwFlags & STARTF_USESTDHANDLES)
+    StartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
+
   result = CreateProcess(szComSpec,
                          szCmdLine,
                          NULL,