Commits

Vinay Sajip committed 0247a72

Closes Issue #6: Avoid launcher termination via Ctrl-C.

Comments (0)

Files changed (1)

CLILauncher/launcher.c

     return ok;
 }
 
+static BOOL WINAPI
+ctrl_c_handler(DWORD code)
+{
+    return TRUE;    /* We just ignore all control events. */
+}
+
 static void
 run_child(wchar_t * cmdline)
 {
     ok = safe_duplicate_handle(GetStdHandle(STD_ERROR_HANDLE), &si.hStdError);
     if (!ok)
         error(0, L"stderr duplication failed");
+
+    ok = SetConsoleCtrlHandler(ctrl_c_handler, TRUE);
+    if (!ok)
+        error(0, L"control handler setting failed");
+
     si.dwFlags = STARTF_USESTDHANDLES;
-    ok = CreateProcessW(NULL, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
+    ok = CreateProcessW(NULL, cmdline, NULL, NULL, TRUE,
+                        0, NULL, NULL, &si, &pi);
     if (!ok)
         error(0, L"Unable to create process using '%s'", cmdline);
     AssignProcessToJobObject(job, pi.hProcess);