// headers
// ----------------------------------------------------------------------------
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
#include "wx/defs.h"
#include "wx/string.h"
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/app.h"
+#include "wx/apptrait.h"
#include "wx/utils.h"
#include "wx/process.h"
#include "wx/unix/execute.h"
-#ifdef __WXBASE__
+#if wxUSE_STREAMS
+
+// define this to let wxexec.cpp know that we know what we're doing
+#define _WX_USED_BY_WXEXECUTE_
+#include "../common/execcmn.cpp"
+
+#endif // wxUSE_STREAMS
+
+#if wxUSE_BASE
#if defined( __MWERKS__ ) && defined(__MACH__)
#define WXWIN_OS_DESCRIPTION "MacOS X"
#if wxUSE_STREAMS
-// ----------------------------------------------------------------------------
-// wxPipeInputStream: stream for reading from a pipe
-// ----------------------------------------------------------------------------
-
-class wxPipeInputStream : public wxFileInputStream
-{
-public:
- wxPipeInputStream(int fd) : wxFileInputStream(fd) { }
-
- // return TRUE if the pipe is still opened
- bool IsOpened() const { return !Eof(); }
-
- // return TRUE if we have anything to read, don't block
- virtual bool CanRead() const;
-};
-
bool wxPipeInputStream::CanRead() const
{
if ( m_lasterror == wxSTREAM_EOF )
}
}
-// define this to let wxexec.cpp know that we know what we're doing
-#define _WX_USED_BY_WXEXECUTE_
-#include "../common/execcmn.cpp"
-
#endif // wxUSE_STREAMS
// ----------------------------------------------------------------------------
{
ARGS_CLEANUP;
+ // save it for WaitForChild() use
+ execData.pid = pid;
+
// prepare for IO redirection
#if wxUSE_STREAMS
#endif // !__WXMAC__
-int wxGetOsVersion(int *verMaj, int *verMin)
-{
- // we want this function to work even if there is no wxApp
- wxConsoleAppTraits traitsConsole;
- wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
- if ( ! traits )
- traits = &traitsConsole;
-
- return traits->GetOSVersion(verMaj, verMin);
-}
-
unsigned long wxGetProcessId()
{
return (unsigned long)getpid();
#endif // WXWIN_COMPATIBILITY_2_2
-#endif // __WXBASE__
+#endif // wxUSE_BASE
#if wxUSE_GUI
bool wxGUIAppTraits::IsWriteFDOfEndProcessPipe(wxExecuteData& execData, int fd)
{
- return fd == execData.pipeEndProcDetect[wxPipe::Write]
+ return fd == (execData.pipeEndProcDetect)[wxPipe::Write];
}
void wxGUIAppTraits::DetachWriteFDOfEndProcessPipe(wxExecuteData& execData)
// process terminates
while ( endProcData->pid != 0 )
{
+ bool idle = true;
+
#if wxUSE_STREAMS
if ( execData.bufOut )
+ {
execData.bufOut->Update();
+ idle = false;
+ }
if ( execData.bufErr )
+ {
execData.bufErr->Update();
+ idle = false;
+ }
#endif // wxUSE_STREAMS
+ // don't consume 100% of the CPU while we're sitting this in this
+ // loop
+ if ( idle )
+ wxUsleep(1);
+
// give GTK+ a chance to call GTK_EndProcessDetector here and
// also repaint the GUI
wxYield();
}
}
+#endif // wxUSE_GUI
+#if wxUSE_BASE
+
void wxHandleProcessTermination(wxEndProcessData *proc_data)
{
// notify user about termination if required
}
}
-#endif // wxUSE_GUI
-
+#endif // wxUSE_BASE