+#endif // wxUSE_STREAMS
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// process termination detecting support
+// ----------------------------------------------------------------------------
+
+// thread function for the thread monitoring the process termination
+static DWORD __stdcall wxExecuteThread(void *arg)
+{
+ wxExecuteData * const data = (wxExecuteData *)arg;
+
+ if ( ::WaitForSingleObject(data->hProcess, INFINITE) != WAIT_OBJECT_0 )
+ {
+ wxLogDebug(_T("Waiting for the process termination failed!"));
+ }
+
+ // get the exit code
+ if ( !::GetExitCodeProcess(data->hProcess, &data->dwExitCode) )
+ {
+ wxLogLastError(wxT("GetExitCodeProcess"));
+ }
+
+ wxASSERT_MSG( data->dwExitCode != STILL_ACTIVE,
+ wxT("process should have terminated") );
+
+ // send a message indicating process termination to the window
+ ::SendMessage(data->hWnd, wxWM_PROC_TERMINATED, 0, (LPARAM)data);
+
+ return 0;
+}
+
+// window procedure of a hidden window which is created just to receive
+// the notification message when a process exits
+LRESULT APIENTRY _EXPORT wxExecuteWindowCbk(HWND hWnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ if ( message == wxWM_PROC_TERMINATED )
+ {
+ DestroyWindow(hWnd); // we don't need it any more
+
+ wxExecuteData * const data = (wxExecuteData *)lParam;
+ if ( data->handler )
+ {
+ data->handler->OnTerminate((int)data->dwProcessId,
+ (int)data->dwExitCode);
+ }
+
+ if ( data->state )
+ {
+ // we're executing synchronously, tell the waiting thread
+ // that the process finished
+ data->state = 0;
+ }
+ else
+ {
+ // asynchronous execution - we should do the clean up
+ delete data;
+ }
+
+ return 0;
+ }
+ else
+ {
+ return ::DefWindowProc(hWnd, message, wParam, lParam);
+ }
+}
+
+// ============================================================================
+// implementation of IO redirection support classes
+// ============================================================================
+
+#if wxUSE_STREAMS && !defined(__WXWINCE__)
+
+// ----------------------------------------------------------------------------
+// wxPipeInputStreams
+// ----------------------------------------------------------------------------