Fix ChannelExec exit status handling
Currently only ChannelShell exit status is handled, so any non-zero error codes from ChannelExec will be just discarded. This PR adds ChannelExec exit status handling.
@@ -197,6 +197,9 @@ public class Main {
channel.setErr(output);
channel.open().verify();
channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
+ if (channel.getExitStatus() != null) {
+ exitStatus = channel.getExitStatus();
+ }
} else {
ChannelShell channel = session.createShellChannel();
Attributes attributes = terminal.enterRawMode();
