code: 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 "
            + Arrays.toString(shexec.getExecString()) + ioe);
        return false;
      }
      return (shexec.getExitCode() == 0 ? true : false);
    }
docs: 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.