private void waitForever() throws InterruptedException, ProcessManagerException { if(process == null) { throw new ProcessManagerException(Strings.get("null.process")); } process.waitFor(); }
private void waitForever() throws InterruptedException, ProcessManagerException { if(process == null) { throw new ProcessManagerException(Strings.get("null.process")); } process.waitFor(); }
/** * Kill the JVM with the given main classname. The classname can be * fully-qualified or just the classname (i.e. without the package name * prepended). * * @param pid * @return a String if the process was not killed for any reason including * if it does not exist. Return null if it was killed. */ public static String killJvm(String classname) { List<Integer> pids = Jps.getPid(classname); StringBuilder sb = new StringBuilder(); int numDead = 0; for (int p : pids) { String s = kill(p); if (s != null) sb.append(s).append('\n'); else ++numDead; } String err = sb.toString(); if (err.length() > 0 || numDead <= 0) return Strings.get("ProcessUtils.killjvmerror", err, numDead); return null; }
/** * Kill the JVM with the given main classname. The classname can be * fully-qualified or just the classname (i.e. without the package name * prepended). * * @param pid * @return a String if the process was not killed for any reason including * if it does not exist. Return null if it was killed. */ public static String killJvm(String classname) { List<Integer> pids = Jps.getPid(classname); StringBuilder sb = new StringBuilder(); int numDead = 0; for (int p : pids) { String s = kill(p); if (s != null) sb.append(s).append('\n'); else ++numDead; } String err = sb.toString(); if (err.length() > 0 || numDead <= 0) return Strings.get("ProcessUtils.killjvmerror", err, numDead); return null; }
private void writeStdin() throws ProcessManagerException { if (stdinLines == null || stdinLines.length <= 0) { return; } PrintWriter pipe = null; if(process == null) { throw new ProcessManagerException(Strings.get("null.process")); } try { pipe = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream()))); for (int i = 0; i < stdinLines.length; i++) { debug("InputLine ->" + stdinLines[i] + "<-"); pipe.println(stdinLines[i]); } pipe.flush(); } catch (Exception e) { throw new ProcessManagerException(e); } finally { try { pipe.close(); } catch (Throwable t) { } } }
private void writeStdin() throws ProcessManagerException { if (stdinLines == null || stdinLines.length <= 0) { return; } PrintWriter pipe = null; if(process == null) { throw new ProcessManagerException(Strings.get("null.process")); } try { pipe = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream()))); for (int i = 0; i < stdinLines.length; i++) { debug("InputLine ->" + stdinLines[i] + "<-"); pipe.println(stdinLines[i]); } pipe.flush(); } catch (Exception e) { throw new ProcessManagerException(e); } finally { try { pipe.close(); } catch (Throwable t) { } } }
return null; else return Strings.get("ProcessUtils.killerror", cmdline, pm.getStderr() + pm.getStdout(), "" + exitValue);
return null; else return Strings.get("ProcessUtils.killerror", cmdline, pm.getStderr() + pm.getStdout(), "" + exitValue);
return null; else return Strings.get("ProcessUtils.killerror", cmdline, pm.getStderr() + pm.getStdout(), "" + exitValue);