msvc: do not pretend to support all signals
authorJeff Hostetler <jeffhost@microsoft.com>
Tue, 25 Jun 2019 14:49:41 +0000 (07:49 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Jun 2019 17:46:58 +0000 (10:46 -0700)
This special-cases various signals that are not supported on Windows,
such as SIGPIPE. These cause the UCRT to throw asserts (at least in
debug mode).

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c
index 667285887a0c536f4b33fcb8cfa7451f23936b69..d01e88c2f80e022c87f9afde65d3703e36f5c73d 100644 (file)
@@ -2119,8 +2119,33 @@ int mingw_raise(int sig)
                        sigint_fn(SIGINT);
                return 0;
 
                        sigint_fn(SIGINT);
                return 0;
 
+#if defined(_MSC_VER)
+       case SIGILL:
+       case SIGFPE:
+       case SIGSEGV:
+       case SIGTERM:
+       case SIGBREAK:
+       case SIGABRT:
+       case SIGABRT_COMPAT:
+               /*
+                * The <signal.h> header in the MS C Runtime defines 8 signals
+                * as being supported on the platform. Anything else causes an
+                * "Invalid signal or error" (which in DEBUG builds causes the
+                * Abort/Retry/Ignore dialog). We by-pass the CRT for things we
+                * already know will fail.
+                */
+               return raise(sig);
+       default:
+               errno = EINVAL;
+               return -1;
+
+#else
+
        default:
                return raise(sig);
        default:
                return raise(sig);
+
+#endif
+
        }
 }
 
        }
 }