This is an automated email from the ASF dual-hosted git repository. luigidemasi pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-kit.git
commit 9cfc32826588efd4b68314e1a66cdfe4040e6d86 Author: Luigi De Masi <[email protected]> AuthorDate: Mon Nov 30 16:01:34 2026 +0100 Fix #110: Stop probes when child enumeration is unavailable The Java runtime can allow starting a command while restricting access to its process handles. Stop the immediate command in either case and await its Process directly. Co-authored-by: OpenAI Codex <[email protected]> --- .../java/org/apache/camel/kit/util/ProcessRunner.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/util/ProcessRunner.java b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/util/ProcessRunner.java index 18296afc..6bcdf2c4 100644 --- a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/util/ProcessRunner.java +++ b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/util/ProcessRunner.java @@ -78,12 +78,18 @@ public final class ProcessRunner { } private static void stopProbe(Process process) { - // Stop the shim first so it cannot advance to its next command when a child exits. - var children = process.descendants().toList(); - process.destroyForcibly(); + List<ProcessHandle> children; + try { + children = process.descendants().toList(); + } catch (UnsupportedOperationException | SecurityException ignored) { + children = List.of(); + } finally { + // Stop the shim first so it cannot advance to its next command when a child exits. + process.destroyForcibly(); + } children.forEach(ProcessHandle::destroyForcibly); - var exits = Stream.concat(Stream.of(process.toHandle()), children.stream()) - .map(ProcessHandle::onExit).toArray(CompletableFuture<?>[]::new); + var exits = Stream.concat(Stream.of(process.onExit()), children.stream().map(ProcessHandle::onExit)) + .toArray(CompletableFuture<?>[]::new); CompletableFuture.allOf(exits).completeOnTimeout(null, 1, TimeUnit.SECONDS).join(); }
