The Command interface has a setExitCallback method that will be called before starting the command. You need to call it to notify the shell that the command has terminated.
On Mon, Jan 3, 2011 at 18:41, Reto Bachmann-Gmuer <[email protected]> wrote: > I read in the FAQ: " MINA doesn't close any connections unless you called > IoSession.close()", so maybe my question should be: How do I get the > IoSession when implementing a Command? > > Cheers, > Reto > > On Mon, Dec 27, 2010 at 4:02 PM, Reto Bachmann-Gmuer <[email protected]>wrote: > >> Hello >> >> I'm connection sshd to my shell service by doing >> >> sshd.setShellFactory(new Factory<Command>() { >> >> @Override >> public Command create() { >> >> return new Command() { >> >> @Override >> public void start(Environment e) throws IOException { >> shell = shellFactory.createShell(in, >> out); >> shell.addTerminationListener(new >> Shell.TerminationListener() { >> public void terminated() { >> try { >> log.info("closing ssh >> stream"); >> out.close(); >> in.close(); >> } catch (IOException ex) { >> log.warn("error closing ssh >> stream", ex); >> } >> }; >> }); >> shell.start(); >> } >> >> >> Unfortunately closing in and out doesn't close the connection instantly, >> only when the user of the ssh client presses a character I get a >> "java.io.IOException: Pipe closed" and the connection is closed. >> >> What's the right way to close the connection to a client? >> >> Cheers, >> Reto >> > -- Cheers, Guillaume Nodet ------------------------ Blog: http://gnodet.blogspot.com/ ------------------------ Open Source SOA http://fusesource.com
