From e6b6d9b325c958a45773e8ed4152c723243173ce Mon Sep 17 00:00:00 2001 From: crschnick Date: Sat, 29 Jun 2024 13:35:38 +0000 Subject: [PATCH] Command read rework --- .../io/xpipe/app/beacon/impl/ShellExecExchangeImpl.java | 6 ++++-- .../src/main/java/io/xpipe/core/process/CommandControl.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/beacon/impl/ShellExecExchangeImpl.java b/app/src/main/java/io/xpipe/app/beacon/impl/ShellExecExchangeImpl.java index 0cc843f2d..738fe60fe 100644 --- a/app/src/main/java/io/xpipe/app/beacon/impl/ShellExecExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/beacon/impl/ShellExecExchangeImpl.java @@ -18,8 +18,10 @@ public class ShellExecExchangeImpl extends ShellExecExchange { AtomicReference err = new AtomicReference<>(); long exitCode; try (var command = existing.getControl().command(msg.getCommand()).start()) { - command.accumulateStdout(s -> out.set(s)); - command.accumulateStderr(s -> err.set(s)); + var r = command.readStdoutAndStderr(); + out.set(r[0]); + err.set(r[1]); + command.close(); exitCode = command.getExitCode(); } return Response.builder() diff --git a/core/src/main/java/io/xpipe/core/process/CommandControl.java b/core/src/main/java/io/xpipe/core/process/CommandControl.java index 34de3bf00..7849cf087 100644 --- a/core/src/main/java/io/xpipe/core/process/CommandControl.java +++ b/core/src/main/java/io/xpipe/core/process/CommandControl.java @@ -69,9 +69,9 @@ public interface CommandControl extends ProcessControl { void withStdoutOrThrow(FailableConsumer c); - String readStdoutDiscardErr() throws Exception; + String[] readStdoutAndStderr() throws Exception; - String readJoinedOutputOrThrow() throws Exception; + String readStdoutDiscardErr() throws Exception; String readStderrDiscardStdout() throws Exception;