// wxExecute() support methods
// ---------------------------
- // called before starting the child process and creates the pipe used for
- // detecting the process termination asynchronously in GUI, does nothing in
- // wxBase
- //
- // if it returns false, we should return from wxExecute() with an error
- virtual bool CreateEndProcessPipe(wxExecuteData& execData);
-
- // test if the given descriptor is the end of the pipe create by the
- // function above
- virtual bool IsWriteFDOfEndProcessPipe(wxExecuteData& execData, int fd);
-
- // ensure that the write end of the pipe is not closed by wxPipe dtor
- virtual void DetachWriteFDOfEndProcessPipe(wxExecuteData& execData);
-
// wait for the process termination, return whatever wxExecute() must
// return
//
execData.process = process;
// create pipes
- if ( !traits->CreateEndProcessPipe(execData) )
+ if ( !execData.pipeEndProcDetect.Create() )
{
wxLogError( _("Failed to execute '%s'\n"), *argv );
if ( fd == pipeIn[wxPipe::Read]
|| fd == pipeOut[wxPipe::Write]
|| fd == pipeErr[wxPipe::Write]
- || traits->IsWriteFDOfEndProcessPipe(execData, fd) )
+ || fd == (execData.pipeEndProcDetect)[wxPipe::Write] )
{
// don't close this one, we still need it
continue;
#endif // !__VMS
// reading side can be safely closed but we should keep the write one
- // opened
- traits->DetachWriteFDOfEndProcessPipe(execData);
+ // opened, it will be only closed when the process terminates resulting
+ // in a read notification to the parent
+ execData.pipeEndProcDetect.Detach(wxPipe::Write);
+ execData.pipeEndProcDetect.Close();
// redirect stdin, stdout and stderr
if ( pipeIn.IsOk() )
// wxExecute support
// ----------------------------------------------------------------------------
-bool wxAppTraits::CreateEndProcessPipe(wxExecuteData& execData)
-{
- return execData.pipeEndProcDetect.Create();
-}
-
-bool wxAppTraits::IsWriteFDOfEndProcessPipe(wxExecuteData& execData, int fd)
-{
- return fd == (execData.pipeEndProcDetect)[wxPipe::Write];
-}
-
-void wxAppTraits::DetachWriteFDOfEndProcessPipe(wxExecuteData& execData)
-{
- execData.pipeEndProcDetect.Detach(wxPipe::Write);
- execData.pipeEndProcDetect.Close();
-}
-
int wxAppTraits::AddProcessCallback(wxEndProcessData *data, int fd)
{
// define a custom handler processing only the closure of the descriptor