/** * Is the process with PID pid still alive? * This method assumes that isAlive is called on a pid that was alive not * too long ago, and hence assumes no chance of pid-wrapping-around. * * @param pid pid of the process to check. * @return true if process is alive. */ public static boolean isAlive(String pid) { ShellCommandExecutor shexec = null; try { String[] args = { "kill", "-0", pid }; shexec = new ShellCommandExecutor(args); shexec.execute(); } catch (ExitCodeException ee) { return false; } catch (IOException ioe) { LOG.warn("Error executing shell command " + shexec.toString() + ioe); return false; } return (shexec.getExitCode() == 0 ? true : false); }
/** * Is the process with PID pid still alive? * This method assumes that isAlive is called on a pid that was alive not * too long ago, and hence assumes no chance of pid-wrapping-around. * * @param pid pid of the process to check. * @return true if process is alive. */ public static boolean isAlive(String pid) { ShellCommandExecutor shexec = null; try { String[] args = { "kill", "-0", pid }; shexec = new ShellCommandExecutor(args); shexec.execute(); } catch (ExitCodeException ee) { return false; } catch (IOException ioe) { LOG.warn("Error executing shell command " + shexec.toString() + ioe); return false; } return (shexec.getExitCode() == 0 ? true : false); }
/** * Is the process with PID pid still alive? * This method assumes that isAlive is called on a pid that was alive not * too long ago, and hence assumes no chance of pid-wrapping-around. * * @param pid pid of the process to check. * @return true if process is alive. */ public static boolean isAlive(String pid) { ShellCommandExecutor shexec = null; try { String[] args = { "kill", "-0", pid }; shexec = new ShellCommandExecutor(args); shexec.execute(); } catch (ExitCodeException ee) { return false; } catch (IOException ioe) { LOG.warn("Error executing shell command " + shexec.toString() + ioe); return false; } return (shexec.getExitCode() == 0 ? true : false); }
/** * Is the process group with still alive? * * This method assumes that isAlive is called on a pid that was alive not * too long ago, and hence assumes no chance of pid-wrapping-around. * * @param pgrpId process group id * @return true if any of process in group is alive. */ public static boolean isProcessGroupAlive(String pgrpId) { ShellCommandExecutor shexec = null; try { String[] args = { "kill", "-0", "-"+pgrpId }; shexec = new ShellCommandExecutor(args); shexec.execute(); } catch (ExitCodeException ee) { return false; } catch (IOException ioe) { LOG.warn("Error executing shell command " + shexec.toString() + ioe); return false; } return (shexec.getExitCode() == 0 ? true : false); }
/** * Is the process group with still alive? * * This method assumes that isAlive is called on a pid that was alive not * too long ago, and hence assumes no chance of pid-wrapping-around. * * @param pgrpId process group id * @return true if any of process in group is alive. */ public static boolean isProcessGroupAlive(String pgrpId) { ShellCommandExecutor shexec = null; try { String[] args = { "kill", "-0", "-"+pgrpId }; shexec = new ShellCommandExecutor(args); shexec.execute(); } catch (ExitCodeException ee) { return false; } catch (IOException ioe) { LOG.warn("Error executing shell command " + shexec.toString() + ioe); return false; } return (shexec.getExitCode() == 0 ? true : false); }
/** * Is the process group with still alive? * * This method assumes that isAlive is called on a pid that was alive not * too long ago, and hence assumes no chance of pid-wrapping-around. * * @param pgrpId process group id * @return true if any of process in group is alive. */ public static boolean isProcessGroupAlive(String pgrpId) { ShellCommandExecutor shexec = null; try { String[] args = { "kill", "-0", "-"+pgrpId }; shexec = new ShellCommandExecutor(args); shexec.execute(); } catch (ExitCodeException ee) { return false; } catch (IOException ioe) { LOG.warn("Error executing shell command " + shexec.toString() + ioe); return false; } return (shexec.getExitCode() == 0 ? true : false); }
/** * Is the process with PID pid still alive? * This method assumes that isAlive is called on a pid that was alive not * too long ago, and hence assumes no chance of pid-wrapping-around. * * @param pid pid of the process to check. * @return true if process is alive. */ public static boolean isAlive(String pid) { ShellCommandExecutor shexec = null; try { String[] args = { "kill", "-0", pid }; shexec = new ShellCommandExecutor(args); shexec.execute(); } catch (ExitCodeException ee) { return false; } catch (IOException ioe) { LOG.warn("Error executing shell command " + shexec.toString() + ioe); return false; } return (shexec.getExitCode() == 0 ? true : false); }
/** * Is the process group with still alive? * * This method assumes that isAlive is called on a pid that was alive not * too long ago, and hence assumes no chance of pid-wrapping-around. * * @param pgrpId process group id * @return true if any of process in group is alive. */ public static boolean isProcessGroupAlive(String pgrpId) { ShellCommandExecutor shexec = null; try { String[] args = { "kill", "-0", "-"+pgrpId }; shexec = new ShellCommandExecutor(args); shexec.execute(); } catch (ExitCodeException ee) { return false; } catch (IOException ioe) { LOG.warn("Error executing shell command " + shexec.toString() + ioe); return false; } return (shexec.getExitCode() == 0 ? true : false); }
public void testShellCommandExecutorToString() throws Throwable { Shell.ShellCommandExecutor sce=new Shell.ShellCommandExecutor( new String[] { "ls","..","arg 2"}); String command = sce.toString(); assertInString(command,"ls"); assertInString(command, " .. "); assertInString(command, "\"arg 2\""); }
public void testShellCommandExecutorToString() throws Throwable { Shell.ShellCommandExecutor sce=new Shell.ShellCommandExecutor( new String[] { "ls", "..","arg 2"}); String command = sce.toString(); assertInString(command,"ls"); assertInString(command, " .. "); assertInString(command, "\"arg 2\""); }
public void testShellCommandExecutorToString() throws Throwable { Shell.ShellCommandExecutor sce=new Shell.ShellCommandExecutor( new String[] { "ls", "..","arg 2"}); String command = sce.toString(); assertInString(command,"ls"); assertInString(command, " .. "); assertInString(command, "\"arg 2\""); }