From 178a0e732640c89eba2f87d34f2d950accf9e127 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Wed, 10 Feb 2016 18:52:51 +0100 Subject: [PATCH] If shutdown command and no IDE instance is running then exit with exit code 0 --- .../platform-impl/src/com/intellij/idea/SocketLock.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/idea/SocketLock.java b/platform/platform-impl/src/com/intellij/idea/SocketLock.java index c62da456a672..0e4585b9f5f3 100644 --- a/platform/platform-impl/src/com/intellij/idea/SocketLock.java +++ b/platform/platform-impl/src/com/intellij/idea/SocketLock.java @@ -133,6 +133,9 @@ public final class SocketLock { } } + if (isShutdownCommand()) { + System.exit(0); + } final String[] lockedPaths = {myConfigPath, mySystemPath}; int workerCount = PlatformUtils.isIdeaCommunity() || PlatformUtils.isDatabaseIDE() || PlatformUtils.isCidr() ? 1 : 2; myServer = BuiltInServer.startNioOrOio(workerCount, 6942, 50, false, new NotNullProducer() { @@ -217,7 +220,7 @@ public final class SocketLock { String response = in.readUTF(); log("read: response=%s", response); if (response.equals(OK_RESPONSE)) { - if (isShutdownCommand(args)) { + if (isShutdownCommand()) { printPID(portNumber); } return ActivateStatus.ACTIVATED; @@ -268,8 +271,8 @@ public final class SocketLock { } } - private static boolean isShutdownCommand(String[] args) { - return args.length != 0 && Pattern.matches(JetBrainsProtocolHandler.PROTOCOL + "[*]?[a-z0-9A-Z]*/shutdown.*", args[0]); + private static boolean isShutdownCommand() { + return "shutdown".equals(JetBrainsProtocolHandler.getCommand()); } private static String[] checkForJetBrainsProtocolCommand(String[] args) {