1. wxProcess changes to make capturing subprocess output easier (and more

reliable), now works in both sync and async modes
2. wxSafeYieldBug() corrected, wxWindowDisabler which is now used in it
   added and documented
3. exec sample updated to illustrate capturing the subprocess output
4. wxStreamBase::IsOk() added
5. wxInputStream::Eof() added and non-blocking Eof() implementation in
   wxPipeInputStream used by wxExecute


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6400 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-03-02 19:06:13 +00:00
parent 21e5527b59
commit cd6ce4a90c
16 changed files with 570 additions and 297 deletions

View File

@@ -158,7 +158,7 @@ protected:
wxPipeInputStream::wxPipeInputStream(HANDLE hInput)
{
m_hInput = hInput;
}
}
wxPipeInputStream::~wxPipeInputStream()
{
@@ -186,7 +186,7 @@ size_t wxPipeInputStream::OnSysRead(void *buffer, size_t len)
wxPipeOutputStream::wxPipeOutputStream(HANDLE hOutput)
{
m_hOutput = hOutput;
}
}
wxPipeOutputStream::~wxPipeOutputStream()
{
@@ -401,32 +401,36 @@ long wxExecute(const wxString& cmd, bool sync, wxProcess *handler)
return result;
#else // 1
HANDLE h_readPipe[2];
HANDLE h_writePipe[2];
HANDLE h_oldreadPipe;
HANDLE h_oldwritePipe;
BOOL inheritHandles;
// ------------------------------------
// Pipe handling
// We are in the case of opening a pipe
// open the pipes to which child process IO will be redirected if needed
inheritHandles = FALSE;
if (handler && handler->NeedPipe()) {
if ( handler && handler->IsRedirected() )
{
SECURITY_ATTRIBUTES security;
security.nLength = sizeof(security);
security.lpSecurityDescriptor = NULL;
security.bInheritHandle = TRUE;
if (! ::CreatePipe(&h_readPipe[0], &h_readPipe[1], &security, 0) ) {
wxLogSysError(_T("Can't create the inter-process read pipe"));
if (! ::CreatePipe(&h_readPipe[0], &h_readPipe[1], &security, 0) )
{
wxLogSysError(_("Can't create the inter-process read pipe"));
return 0;
}
if (! ::CreatePipe(&h_writePipe[0], &h_writePipe[1], &security, 0) ) {
wxLogSysError(_T("Can't create the inter-process read pipe"));
if (! ::CreatePipe(&h_writePipe[0], &h_writePipe[1], &security, 0) )
{
::CloseHandle(h_readPipe[0]);
::CloseHandle(h_readPipe[1]);
wxLogSysError(_("Can't create the inter-process write pipe"));
return 0;
}
@@ -464,12 +468,14 @@ long wxExecute(const wxString& cmd, bool sync, wxProcess *handler)
&pi // process info
) == 0 )
{
if (inheritHandles) {
if ( inheritHandles )
{
::CloseHandle(h_writePipe[0]);
::CloseHandle(h_writePipe[1]);
::CloseHandle(h_readPipe[0]);
::CloseHandle(h_readPipe[1]);
}
wxLogSysError(_("Execution of command '%s' failed"), command.c_str());
return 0;
@@ -589,16 +595,17 @@ long wxExecute(const wxString& cmd, bool sync, wxProcess *handler)
// waiting until command executed (disable everything while doing it)
#if wxUSE_GUI
wxBeginBusyCursor();
wxEnableTopLevelWindows(FALSE);
{
wxBusyCursor bc;
wxWindowDisabler wd;
#endif // wxUSE_GUI
while ( data->state )
wxYield();
#if wxUSE_GUI
wxEnableTopLevelWindows(TRUE);
wxEndBusyCursor();
}
#endif // wxUSE_GUI
DWORD dwExitCode = data->dwExitCode;