* @param pid the PID of the process that was launched, cannot be <code>null</code>;
* @param launcher the terminated process to handle, cannot be <code>null</code>.
* @throws IOException in case of I/O problems during the respawn of a terminated process.
*/
private boolean processNeedsToBeRespawned(String pid, ProcessLauncher launcher) throws IOException {
LaunchConfiguration config = launcher.getLaunchConfiguration();
Integer exitValue = launcher.getExitValue();
// Is the process non-successfully terminated?
if (isNonSuccessfullyTerminated(config, exitValue)) {
// If so, does it need to be respawned?
if (config.isRespawnAutomatically()) {
// We need to respawn the process automatically!
String logLine =
String.format("Process %s (%s) terminated with value %d;" + " respawning it as requested...", pid,
config.getExecutableName(), exitValue);
m_logger.log(LogService.LOG_INFO, logLine);
// Simply relaunch the process again...
return true;
}
else {
// Don't bother restarting the process...
String logLine =
String.format("Process %s (%s) terminated with value %d.", pid, config.getExecutableName(),
exitValue);
m_logger.log(LogService.LOG_INFO, logLine);
}
}
else {
// Process ended normally...
String logLine = String.format("Process %s (%s) terminated normally.", pid, config.getExecutableName());
m_logger.log(LogService.LOG_INFO, logLine);
}
return false;
}