Prevent race conditions during CLI install  (#2523)

* Use a special exitcode when connecting to CLI as client. Do not run upgrade step thereafter.

* Piggyback with NBJLS server relaunch after installation completes.

* Delay and/or disable the restart LSP client after connection termination
with the hope to finish install tasks meanwhile and then restart explicitly

* Wait after last child closes on Win.

* Fixed launchers release number -> release.

Co-authored-by: Jaroslav Tulach <jaroslav.tulach@oracle.com>
diff --git a/nbexec.cpp b/nbexec.cpp
index 2e63d02..47e490e 100644
--- a/nbexec.cpp
+++ b/nbexec.cpp
@@ -43,9 +43,16 @@
     return TRUE;
 }
 
+volatile int exitStatus = 0;
+
 void exitHook(int status) {
+    exitStatus = status;
     logMsg("Exit hook called with status %d", status);
-    launcher.onExit();
+    // do not handle possible restarts, if we are just CLI-connecting to a running process.
+    if (status != -252) {
+        launcher.onExit();
+    }
+    logMsg("Exit hook terminated.");
 }
 
 #define NBEXEC_EXPORT extern "C" __declspec(dllexport)
diff --git a/platformlauncher.cpp b/platformlauncher.cpp
index b29b309..8df954c 100644
--- a/platformlauncher.cpp
+++ b/platformlauncher.cpp
@@ -24,6 +24,8 @@
 #include "platformlauncher.h"
 #include "argnames.h"
 
+volatile extern int exitStatus;
+
 using namespace std;
 
 const char *PlatformLauncher::HELP_MSG =
@@ -662,6 +664,10 @@
 
 void PlatformLauncher::onExit() {
     logMsg("onExit()");
+    if (exitStatus == -252) {
+        logMsg("Exiting from CLI client, will not restart.");
+        return;
+    }
     
     if (exiting) {
         logMsg("Already exiting, no need to schedule restart");
@@ -714,7 +720,8 @@
         STARTUPINFO si = {0};
         PROCESS_INFORMATION pi = {0};
         si.cb = sizeof(STARTUPINFO);
-        if (!CreateProcess(NULL, cmdLineStr, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
+
+        if (!CreateProcess(NULL, cmdLineStr, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) {
             logErr(true, true, "Failed to create process.");
             return;
         }