Skip to content

Commit

Permalink
recheck thread exit code before reporting doa minion
Browse files Browse the repository at this point in the history
  • Loading branch information
hcoles committed Oct 31, 2023
1 parent c55ee14 commit 56ca9e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ public ExitCode waitToDie() {
while (!maybeExit.isPresent() && this.process.isAlive()) {
maybeExit = this.crt.waitToFinish(10);
}

// Either the monitored process died, or the thread ended.
// Check the thread one last time to try and avoid reporting
// an error code if it was the process that went down first
maybeExit = this.crt.waitToFinish(10);

return maybeExit.orElse(ExitCode.MINION_DIED);
} finally {
this.process.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public ExitCode waitToDie() {
try {
// Wait a moment to give the monitoring thread time to finish naturally. This
// happens when the monitored process sends a "DONE" signal over the socket,
// the process itself should exit shortly after sending the signal
// the process itself should exit shortly after sending the signal.
// Most likely the process will still be running
Optional<ExitCode> maybeExit = this.thread.waitToFinish(5);

// While the monitored process reports being alive, keep polling
Expand All @@ -60,6 +61,11 @@ public ExitCode waitToDie() {
maybeExit = this.thread.waitToFinish(10);
}

// Either the monitored process died, or the thread ended.
// Check the thread one last time to try and avoid reporting
// an error code if it was the process that went down first
maybeExit = this.thread.waitToFinish(10);

// If the monitored thread is still live, but the process is dead
// then either the process never properly started or it died
// before reporting its exit
Expand Down

0 comments on commit 56ca9e8

Please sign in to comment.