protected boolean isVmWithProcessIdRunning(final Integer pid) { // note: this will use JNA if available or Attach if available or return false if neither is available return ProcessUtils.isProcessAlive(pid); }
ignorePidFile = !ProcessUtils.isProcessAlive(otherPid);
ignorePidFile = !ProcessUtils.isProcessAlive(otherPid);
if (!ProcessUtils.isProcessAlive(process)) { if (!continueReading.isRunning()) { continueReading.start();
public void testStatusWithStalePidFile() throws Exception { this.workingDirectory = new File(getUniqueName()); this.workingDirectory.mkdir(); assertTrue(this.workingDirectory.isDirectory() && this.workingDirectory.canWrite()); this.pidFile = new File(this.workingDirectory, ProcessType.SERVER.getPidFileName()); final int pid = 0; assertFalse(ProcessUtils.isProcessAlive(pid)); writePid(this.pidFile, pid); final ServerLauncher dirLauncher = new ServerLauncher.Builder() .setWorkingDirectory(workingDirectory.getCanonicalPath()) .build(); try { dirLauncher.status(); fail("Status should have thrown IllegalArgumentException"); } catch (IllegalArgumentException e) { String expected = "Invalid pid '" + pid + "' found in " + this.pidFile.getCanonicalPath(); assertEquals("Message was " + e.getMessage() + " instead of " + expected, expected, e.getMessage()); } } // testStatusWithStalePidFile
public void testStatusWithStalePidFile() throws Exception { this.workingDirectory = new File(getUniqueName()); this.workingDirectory.mkdir(); assertTrue(this.workingDirectory.isDirectory() && this.workingDirectory.canWrite()); this.pidFile = new File(this.workingDirectory, ProcessType.LOCATOR.getPidFileName()); final int pid = 0; assertFalse(ProcessUtils.isProcessAlive(pid)); writePid(this.pidFile, pid); final LocatorLauncher dirLauncher = new LocatorLauncher.Builder() .setWorkingDirectory(workingDirectory.getCanonicalPath()) .build(); try { dirLauncher.status(); fail("Status should have thrown IllegalArgumentException"); } catch (IllegalArgumentException e) { String expected = "Invalid pid '" + pid + "' found in " + this.pidFile.getCanonicalPath(); assertEquals("Message was " + e.getMessage() + " instead of " + expected, expected, e.getMessage()); } } // testStatusWithStalePidFile