mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Don't fail on killing, only log the error.
This commit is contained in:
+10
-6
@@ -40,6 +40,7 @@ public class KillableColoredProcessHandler extends ColoredProcessHandler impleme
|
||||
|
||||
/**
|
||||
* This method shouldn't be overriden, see shouldKillProcessSoftly
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean canKillProcessSoftly() {
|
||||
@@ -52,17 +53,20 @@ public class KillableColoredProcessHandler extends ColoredProcessHandler impleme
|
||||
if (canKillProcessSoftly() && shouldKillProcessSoftly()) {
|
||||
// Unix: [soft-kill] at first send INT signal:
|
||||
final Process process = getProcess();
|
||||
UnixProcessManager.sendSigIntToProcessTree(process);
|
||||
}
|
||||
else {
|
||||
// if soft kill isn't supported - use default implementation
|
||||
super.doDestroyProcess();
|
||||
// else IDE will suggest 'terminate dialog'
|
||||
if (UnixProcessManager.sendSigIntToProcessTree(process)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if soft kill isn't supported - use default implementation
|
||||
super.doDestroyProcess();
|
||||
// else IDE will suggest 'terminate dialog'
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should be overriden by children if the process shouldn't be killed softly (e.g. by kill -2)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected boolean shouldKillProcessSoftly() {
|
||||
|
||||
@@ -32,6 +32,8 @@ import java.util.*;
|
||||
* @author traff
|
||||
*/
|
||||
public class UnixProcessManager {
|
||||
private static final Logger LOG = Logger.getInstance(UnixProcessManager.class);
|
||||
|
||||
public static final int SIGINT = 2;
|
||||
public static final int SIGKILL = 9;
|
||||
public static final int SIGTERM = 15;
|
||||
@@ -104,6 +106,7 @@ public class UnixProcessManager {
|
||||
* @param process tree root process
|
||||
*/
|
||||
public static boolean sendSignalToProcessTree(Process process, int signal) {
|
||||
try {
|
||||
checkCLib();
|
||||
|
||||
final int our_pid = C_LIB.getpid();
|
||||
@@ -138,6 +141,11 @@ public class UnixProcessManager {
|
||||
else {
|
||||
return true; //the parent process was already killed
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//If we fail somehow just return false
|
||||
LOG.warn("Error killing the process", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void findChildProcesses(final int our_pid,
|
||||
@@ -208,7 +216,7 @@ public class UnixProcessManager {
|
||||
errorStr.append(s).append("\n");
|
||||
}
|
||||
if (errorStr.length() > 0) {
|
||||
throw new IllegalStateException("error:" + errorStr.toString());
|
||||
throw new IOException("Error reading ps output:" + errorStr.toString());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
Reference in New Issue
Block a user