Skip to content

Commit 3966b50

Browse files
committed
Mark ProcessIoProxy done when the underlying process has terminated
1 parent 8446c42 commit 3966b50

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

mcp/mcp-cli/src/main/java/software/amazon/smithy/java/mcp/cli/ProcessIoProxy.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,21 @@ public synchronized void start() {
222222
running);
223223
}
224224

225+
// Thread to monitor process exit and signal completion
226+
Thread.ofVirtual()
227+
.name("process-exit-monitor")
228+
.start(() -> {
229+
try {
230+
process.waitFor();
231+
} catch (InterruptedException e) {
232+
LOG.error("Process exit monitor interrupted", e);
233+
Thread.currentThread().interrupt();
234+
} finally {
235+
running.set(false);
236+
done.countDown();
237+
}
238+
});
239+
225240
} catch (IOException e) {
226241
running.set(false);
227242
throw new RuntimeException("Failed to start process: " + e.getMessage(), e);

0 commit comments

Comments
 (0)