mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 17:10:27 +00:00
Command read rework
This commit is contained in:
parent
f6c06b38c3
commit
e6b6d9b325
2 changed files with 6 additions and 4 deletions
|
@ -18,8 +18,10 @@ public class ShellExecExchangeImpl extends ShellExecExchange {
|
||||||
AtomicReference<String> err = new AtomicReference<>();
|
AtomicReference<String> err = new AtomicReference<>();
|
||||||
long exitCode;
|
long exitCode;
|
||||||
try (var command = existing.getControl().command(msg.getCommand()).start()) {
|
try (var command = existing.getControl().command(msg.getCommand()).start()) {
|
||||||
command.accumulateStdout(s -> out.set(s));
|
var r = command.readStdoutAndStderr();
|
||||||
command.accumulateStderr(s -> err.set(s));
|
out.set(r[0]);
|
||||||
|
err.set(r[1]);
|
||||||
|
command.close();
|
||||||
exitCode = command.getExitCode();
|
exitCode = command.getExitCode();
|
||||||
}
|
}
|
||||||
return Response.builder()
|
return Response.builder()
|
||||||
|
|
|
@ -69,9 +69,9 @@ public interface CommandControl extends ProcessControl {
|
||||||
|
|
||||||
void withStdoutOrThrow(FailableConsumer<InputStreamReader, Exception> c);
|
void withStdoutOrThrow(FailableConsumer<InputStreamReader, Exception> c);
|
||||||
|
|
||||||
String readStdoutDiscardErr() throws Exception;
|
String[] readStdoutAndStderr() throws Exception;
|
||||||
|
|
||||||
String readJoinedOutputOrThrow() throws Exception;
|
String readStdoutDiscardErr() throws Exception;
|
||||||
|
|
||||||
String readStderrDiscardStdout() throws Exception;
|
String readStderrDiscardStdout() throws Exception;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue