size_t nwxProcess::ProcessIO(size_t nLimit) { size_t nRtn = 0; bool bInputClosed = false; if(!m_bPaused) { if(!IsInputOpened()) { if(m_sBuffer.Len()) { m_sBuffer += "\n"; ProcessLine(m_sBuffer.utf8_str(),m_sBuffer.Len(),false); m_sBuffer.Empty(); } bInputClosed = true; } else { while(IsInputAvailable() && (nRtn < nLimit)) { nRtn += ProcessIO(GetInputStream(),m_sBuffer,false); } } if(!IsErrorOpened()) { if(m_sBufferError.Len()) { m_sBufferError += "\n"; ProcessLine(m_sBufferError.utf8_str(),m_sBufferError.Len(),true); m_sBufferError.Empty(); } if(bInputClosed && m_bRunning) { m_bRunning = false; // we are sometimes not notified when process ends #ifndef __WXMSW__ // need to clean up zombie because wx sometimes // fails to do this on the macintosh int nStatLoc; pid_t nPID; nPID = waitpid((pid_t)m_nPID,&nStatLoc,0); OnTerminate(m_nPID,nStatLoc); #endif } } else { while(IsErrorAvailable() && (nRtn < nLimit)) { nRtn += ProcessIO(GetErrorStream(),m_sBufferError,true); } } } return nRtn; }
bool wxGISProcess::Start() { m_pid = Execute(); if(m_pid == 0) return false; m_nState = enumGISTaskWork; m_dtBeg = wxDateTime::Now(); m_dfDone = 0; //create and start read thread stdin if(IsInputOpened()) { return CreateAndRunReadThread(); } //start err thread ? return true; //or false? }