Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix #289 #290

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,9 @@ private void launchAndRead() throws Exception {

// fire the STOPPED handler if it had fully started previously
if (os != null)
Handler.tryHandle(_stoppedCallback, process.exitValue(), _callbackErrorHandler);
// .waitFor() is required instead of .exitValue() because it is possible (but rare) to get here
// with the process not fully dead and cleaned up yet
Handler.tryHandle(_stoppedCallback, process.waitFor(), _callbackErrorHandler);

// propagate exception only on unusual termination
if (_state == State.Started)
Expand Down Expand Up @@ -835,7 +837,7 @@ private void readTextLoop(Process process) throws Exception {
handleReceivedData(str);

// then fire the stopped event and pass through the exit value
Handler.tryHandle(_stoppedCallback, _process.waitFor(), _callbackErrorHandler);
Handler.tryHandle(_stoppedCallback, process.waitFor(), _callbackErrorHandler);
}
}

Expand Down Expand Up @@ -901,7 +903,7 @@ public void run() {
* No read-delimiters specified, so fire events as data segments arrive.
* (suppress was used with resource-free CountableInputStream)
*/
private void readUnboundedRawLoop(Process process) throws IOException {
private void readUnboundedRawLoop(Process process) throws Exception {
InputStream stdout = process.getInputStream();

@SuppressWarnings("resource")
Expand All @@ -926,8 +928,8 @@ private void readUnboundedRawLoop(Process process) throws IOException {
// the peer has gracefully closed down the connection or we're shutting down

if (!_shutdown) {
// then fire the disconnected callback
Handler.tryHandle(_stoppedCallback, _process.exitValue(), _callbackErrorHandler);
// then fire the stopped callback
Handler.tryHandle(_stoppedCallback, process.waitFor(), _callbackErrorHandler);
}
}

Expand Down