if (sess.getExitStatus() == null) { if (sess.getExitStatus() != null && sess.getExitStatus().intValue() != 0) { s_logger.error(String.format("SSH execution of command %s has an error status code in return. Result output: %s", command, result)); return new Pair<Boolean, String>(false, result);
Integer status = sshSession.getExitStatus(); if( status != null ) { result.setReturnCode(status);
@Override public boolean isAlive() { return ssh.getExitStatus()==null; }
public boolean isAlive() throws IOException, InterruptedException { return session.getExitStatus()==null; }
public Integer getExitCode() { return mySession.getExitStatus(); }
public boolean isAlive() throws IOException, InterruptedException { return session.getExitStatus()==null; }
private int waitCompletion(Session session) throws InterruptedException { // I noticed that the exit status delivery often gets delayed. Wait up // to 1 sec. for (int i = 0; i < 10; i++) { Integer r = session.getExitStatus(); if (r != null) return r; Thread.sleep(100); } return -1; }
private int waitCompletion(Session session) throws InterruptedException { // I noticed that the exit status delivery often gets delayed. Wait up to 1 sec. for( int i=0; i<10; i++ ) { Integer r = session.getExitStatus(); if(r!=null) return r; Thread.sleep(100); } return -1; }
@Override public int waitFor() throws InterruptedException { ssh.waitForCondition(ChannelCondition.EXIT_STATUS,0); return ssh.getExitStatus(); }
@Override public int exitValue() { Integer v = ssh.getExitStatus(); if (v==null) throw new IllegalThreadStateException(); return v; }
@Override public int exitValue() { Integer i = s.getExitStatus(); if (i==null) throw new IllegalThreadStateException(); // hasn't finished return i; }
public int join() throws IOException, InterruptedException { try { t1.join(); t2.join(); t3.join(); session.waitForCondition(ChannelCondition.EXIT_STATUS,0); Integer r = session.getExitStatus(); if(r!=null) return r; return -1; } finally { session.close(); } }
public int join() throws IOException, InterruptedException { try { t1.join(); t2.join(); t3.join(); session.waitForCondition(ChannelCondition.EXIT_STATUS,0); Integer r = session.getExitStatus(); if(r!=null) return r; return -1; } finally { session.close(); } }
/** * Find the exit code or exit status, which are differentiated in SSH protocol. */ private String getSessionOutcomeMessage(Session session, boolean isConnectionLost) throws InterruptedException { session.waitForCondition(ChannelCondition.EXIT_STATUS | ChannelCondition.EXIT_SIGNAL, 3000); Integer exitCode = session.getExitStatus(); if (exitCode != null) return "Slave JVM has terminated. Exit code=" + exitCode; String sig = session.getExitSignal(); if (sig != null) return "Slave JVM has terminated. Exit signal=" + sig; if (isConnectionLost) return "Slave JVM has not reported exit code before the socket was lost"; return "Slave JVM has not reported exit code. Is it still running?"; }
/** * Find the exit code or exit status, which are differentiated in SSH protocol. */ private String getSessionOutcomeMessage(Session session, boolean isConnectionLost) throws InterruptedException { session.waitForCondition(ChannelCondition.EXIT_STATUS | ChannelCondition.EXIT_SIGNAL, 3000); Integer exitCode = session.getExitStatus(); if (exitCode != null) return "Slave JVM has terminated. Exit code=" + exitCode; String sig = session.getExitSignal(); if (sig != null) return "Slave JVM has terminated. Exit signal=" + sig; if (isConnectionLost) return "Slave JVM has not reported exit code before the socket was lost"; return "Slave JVM has not reported exit code. Is it still running?"; }
exec.awaitTermination(2, TimeUnit.DAYS); if (logger.isInfoEnabled()) { logger.info("exit status -->" + session.getExitStatus());
final Integer status = sshSession.getExitStatus(); if (status != null) { return status;
log.debug("ExitCode is: " + session.getExitStatus());
exec.shutdown(); if (logger.isInfoEnabled()) { logger.info("exit status -->" + session.getExitStatus());
/** * Executes a process remotely and blocks until its completion. * * @param command the command * @param output The stdout/stderr will be sent to this stream. * @return the int * @throws IOException the io exception * @throws InterruptedException the interrupted exception */ public int exec(String command, OutputStream output) throws IOException, InterruptedException { Session session = openSession(); try { session.execCommand(command); PumpThread t1 = new PumpThread(session.getStdout(), output); t1.start(); PumpThread t2 = new PumpThread(session.getStderr(), output); t2.start(); session.getStdin().close(); t1.join(); t2.join(); // wait for some time since the delivery of the exit status often gets delayed session.waitForCondition(ChannelCondition.EXIT_STATUS,3000); Integer r = session.getExitStatus(); if(r!=null) return r.intValue(); return -1; } finally { session.close(); } }