code: public static boolean isPIDAlive(final int pid) throws IOException {
      final String ps = "ps";
      final String command[] = new String[] { ps, "-fp", pid + "" };
      final StringBuffer in = new StringBuffer();
      final Process process = Runtime.getRuntime().exec(command);
      
      InputStream inStream = process.getInputStream();
      InputStream errStream = process.getErrorStream();
      // wait for the process to complete.
      try {
        process.waitFor();
      } catch (final InterruptedException ignored) {
      }
      
      while (inStream.available() > 0) {
        in.append((char) inStream.read());
      }
      while (errStream.available() > 0) {
        in.append((char) errStream.read());
      }
      
      process.destroy();
      inStream.close();
      inStream = null;
      errStream.close();
      errStream = null;
      
      if (in.indexOf(pid + "") > 0)
        return true;
      return false;
    }
docs: Returns true if the given pid is alive. Requires /bin/ps (ie UNIX)