You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Mikael Östberg <os...@gmail.com> on 2021/03/05 11:50:14 UTC

Recieving CLOSED without a EXIT_CODE

Hello fabulous developers of Apache MINA.

I'm troubleshooting a strange behavior in our usage of sshd-core. We're
using the version below.

<dependency>
   <groupId>org.apache.sshd</groupId>
   <artifactId>sshd-core</artifactId>
   <version>2.5.1</version>

</dependency>


*Consider the following code: *

ChannelExec ce = session.createExecChannel(envCommand + command, new
PtyChannelConfiguration(), env);

...

Set<ClientChannelEvent> events =
ce.waitFor(EnumSet.of(ClientChannelEvent.CLOSED),
waitTime.toMillis());
if (events.contains(ClientChannelEvent.TIMEOUT)) {
   throw new RuntimeException("Command [" + command + "] timed out!");
}
return new SshResult(out.toString(), err.toString(), ce.getExitStatus());

However, at this point where we have waited for a
*ClientChannelEvent.CLOSED *we expect a returnCode to be present in
*ce. *Since then we have been proven wrong in this assumption since
we're sometimes receiving an NPE further down the line on a null
ExitCode. Fair enough, we have handle a nullcheck and the assumptions
that entails.


*My question is this: *

Under what circumstances ssh-wise can we end up in this situation that
we have a closed channel, which isn't a timeout, that is also missing
a returncode.

Even a SIGINTERRUPT or SIGKILL should cause some kind of returnCode?
How should we interpret the behavior? Network issues?


Thank you for your time,

Mikael Östberg

Sweden