void onExit( int pid, int exitValue) { |
ProcessReference processReference = null ; |
synchronized (processReferences) { |
cleanUp(); |
if (pid >= 0 ) { |
processReference = processReferences.remove(pid); |
} else if (exitValue == WAIT_STATUS_NO_CHILDREN) { |
if (processReferences.isEmpty()) { |
/** |
* There are no eligible children; wait for one to be |
* added. The wait() will return due to the |
* notifyAll() call below. |
*/ |
try { |
processReferences.wait(); |
} catch (InterruptedException ex) { |
// This should never happen. |
throw new AssertionError( "unexpected interrupt" ); |
} |
} else { |
/** |
* A new child was spawned just before we entered |
* the synchronized block. We can just fall through |
* without doing anything special and land back in |
* the native wait(). |
*/ |
} |
} else { |
// Something weird is happening; abort! |
throw new AssertionError( "unexpected wait() behavior" ); |
} |
} |
if (processReference != null ) { |
ProcessImpl process = processReference.get(); |
if (process != null ) { |
process.setExitValue(exitValue); |
} |
} |
} //源代码片段来自云代码http://yuncode.net |
|