public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix __gnat_kill on Windows
@ 2022-01-07 16:27 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-01-07 16:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: Dmitriy Anisimkov

[-- Attachment #1: Type: text/plain, Size: 276 bytes --]

Terminate process only on terminating signals.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* adaint.c (__gnat_kill): Terminate process only in case of
	SIGKILL, SIGINT, SIGBREAK, SIGTERM, SIGABRT.  Do not call
	OpenProcess if not going to terminate process.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 737 bytes --]

diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -3559,13 +3559,21 @@ void
 __gnat_kill (int pid, int sig, int close ATTRIBUTE_UNUSED)
 {
 #if defined(_WIN32)
-  HANDLE h = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pid);
-  if (h == NULL)
-    return;
+  HANDLE h;
 
-  TerminateProcess (h, sig);
+  switch (sig) {
+    case 9: // SIGKILL is not declared in Windows headers
+    case SIGINT:
+    case SIGBREAK:
+    case SIGTERM:
+    case SIGABRT:
+      h = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pid);
+      if (h != NULL) {
+        TerminateProcess (h, sig);
+        CloseHandle (h);
+      }
+  }
 
-  CloseHandle (h);
 #elif defined (__vxworks)
   /* Not implemented */
 #else



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-07 16:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07 16:27 [Ada] Fix __gnat_kill on Windows Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).