Browse Source

Make sure all output is processed and none is left buffered when the native process completes

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270868 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
7b38537d18
1 changed files with 15 additions and 3 deletions
  1. +15
    -3
      proposal/myrmidon/src/java/org/apache/aut/nativelib/impl/ProcessMonitor.java

+ 15
- 3
proposal/myrmidon/src/java/org/apache/aut/nativelib/impl/ProcessMonitor.java View File

@@ -118,9 +118,7 @@ class ProcessMonitor
{ {
while( STATE_RUNNING == m_state ) while( STATE_RUNNING == m_state )
{ {
processStandardInput();
processStandardOutput();
processStandardError();
processStreams();


if( !isProcessStopped() ) if( !isProcessStopped() )
{ {
@@ -137,11 +135,25 @@ class ProcessMonitor
} }
} }


//Process streams again to make sure
//that we have got all the data
processStreams();

IOUtil.shutdownStream( m_input ); IOUtil.shutdownStream( m_input );
IOUtil.shutdownStream( m_output ); IOUtil.shutdownStream( m_output );
IOUtil.shutdownStream( m_error ); IOUtil.shutdownStream( m_error );
} }


/**
* Utility method to process all the standard streams.
*/
private void processStreams()
{
processStandardInput();
processStandardOutput();
processStandardError();
}

/** /**
* Check if process has stopped. If it has then update state * Check if process has stopped. If it has then update state
* and return true, else return false. * and return true, else return false.


Loading…
Cancel
Save