/** * Stops the process. */ public synchronized void stop() { if (mProcess != null) { mProcess.destroyForcibly(); mProcess = null; } } }
public void destroyForcibly() { process.destroyForcibly(); }
public void killForcibly() { this.killed = true; process.destroyForcibly(); }
@Override public void cancel() { logger.info(String .format("Canceling a single task process. job name: %s. job id: %s", this.jobName, this.jobId)); this.taskProcess.destroyForcibly(); } }
@Override public void close() { try { underlyingReader.close(); } catch (IOException e) { // Ignored } finally { process.destroy(); try { if (!process.waitFor(5, TimeUnit.SECONDS)) { process.destroyForcibly(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); process.destroyForcibly(); } } } }
/** * this only kills the process of "gfsh -e command", it does not kill the child processes started * by this command. */ public void killProcess() { process.destroyForcibly(); if (process.isAlive()) { // process may not terminate immediately after destroyForcibly boolean exited = false; try { exited = process.waitFor(1, TimeUnit.MINUTES); } catch (InterruptedException e) { throw new RuntimeException(e.getMessage(), e); } if (!exited) { throw new RuntimeException("failed to destroy the process of " + workingDir.getName()); } } }
/** * {@link #reset()}, and close any running ctags instance. * @throws IOException not really thrown -- but logged */ public void close() throws IOException { reset(); IOUtils.close(ctagsIn); if (ctags != null) { closing = true; LOGGER.log(Level.FINE, "Destroying ctags command"); ctags.destroyForcibly(); } }
ctags.destroyForcibly(); } catch (Exception e) { LOGGER.log(Level.WARNING, "ctags problem:", e); ctags.destroyForcibly();
/** * Kills the mandoc process if it is running */ public void destroy() { // terminate straightaway any existing run if (errThread != null) { errThread.interrupt(); errThread = null; } if (mandoc != null) { Process destroying = mandoc; mandoc = null; if (mandocIn != null) { IOUtils.close(mandocIn); mandocIn = null; } if (mandocOut != null) { IOUtils.close(mandocOut); mandocOut = null; } destroying.destroyForcibly(); } } }
protected <T> T runCommandWithExceptions(String[] command, Function<BufferedReader, T> resultParser) throws IOException, InterruptedException { Process p = new ProcessBuilder(command) // important to grab input from the Java process... THis provides a way for the terminal commands // like "stty" to make sense of the calling environment... .redirectInput(ProcessBuilder.Redirect.INHERIT) .start(); if (!p.waitFor(3, TimeUnit.SECONDS)) { logger.trace(() -> "Command '" + toString(command) + "' is stuck, killing"); p.destroyForcibly(); return null; } if (p.exitValue() != 0) { logger.trace(() -> "Command '" + toString(command) + "' failure. Exit code: " + p.exitValue()); return null; } try (BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()))) { return resultParser.apply(r); } } }
process.destroyForcibly(); if (writeOutput != null) { writeOutput.cancel(true); Process process = processReference.get(); if (process != null) { process.destroyForcibly();
@OnUnscheduled public void shutdownExecutor() { try { executor.shutdown(); } finally { if (this.externalProcess.isAlive()) { this.getLogger().info("Process hasn't terminated, forcing the interrupt"); this.externalProcess.destroyForcibly(); } } }
/** * Joins with the consumer Threads. Calls {@link Thread#join()} on the two * consumers. */ public void done() { if ( process.isAlive() ) { process.destroyForcibly(); } try { out.join(); } catch ( InterruptedException e ) { Thread.interrupted(); e.printStackTrace(); } try { err.join(); } catch ( InterruptedException e ) { Thread.interrupted(); e.printStackTrace(); } }
@Override public Integer retriableCall() throws Exception { while (true) { sleeper.sleep(config.getPostRestoreHookHeartbeatCheckFrequencyInMs()); if (System.currentTimeMillis() - heartBeatFile.lastModified() > config.getPostRestoreHookHeartBeatTimeoutInMs()) { // kick off post restore hook process, since there is no heartbeat logger.info( "No heartbeat for the last {} ms, killing the existing process.", config.getPostRestoreHookHeartBeatTimeoutInMs()); if (process.isAlive()) { process.destroyForcibly(); } return 0; } } } });
@Test public void testCancel() throws IOException { createAndRunTask(); this.task.cancel(); verify(this.mockProcess).destroyForcibly(); }
_reaperExecutor.schedule(() -> { if (process.isAlive()) { process.destroyForcibly();
process.destroyForcibly();
@Test public void ProcessMonitorImpl_is_a_proxy_of_Process() throws Exception { Process process = mock(Process.class, RETURNS_DEEP_STUBS); ProcessCommands commands = mock(ProcessCommands.class, RETURNS_DEEP_STUBS); ProcessCommandsProcessMonitor underTest = new ProcessCommandsProcessMonitor(process, ProcessId.WEB_SERVER, commands); underTest.waitFor(); verify(process).waitFor(); underTest.closeStreams(); verify(process.getErrorStream()).close(); verify(process.getInputStream()).close(); verify(process.getOutputStream()).close(); underTest.destroyForcibly(); verify(process).destroyForcibly(); assertThat(underTest.getInputStream()).isNotNull(); underTest.isAlive(); verify(process).isAlive(); underTest.waitFor(123, TimeUnit.MILLISECONDS); verify(process).waitFor(123, TimeUnit.MILLISECONDS); }
process.destroyForcibly();
process.destroyForcibly(); afterNodeKilled(i, process);