1

In the UCRT signal.h, I see these defines.

#define SIGABRT         22  // abnormal termination triggered by abort call

#define SIGABRT_COMPAT  6   // SIGABRT compatible with other platforms, same as SIGABRT

Full path is c:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\signal.h if it helps.

In man signal.7 on my Ubuntu 18.04 system I see SIGABRT is also mapped to 6.

This is confusing to me. Being that Windows doesn't truly have "signals" under the hood, and this is all an emulation layer on top of the various messaging mechanisms native to Windows wrapped by the C++11 standard library, why did they choose something non-portable for the default SIGABRT? Do they expect people to be using it as an argument to raise(), or for comparison in a signal handler?

The only documentation I can find regarding the existence of SIGABRT_COMPAT is the comment in the header file, and the table in the online documentation which is no more descriptive than the header.

The standard doesn't even define it: https://en.cppreference.com/w/cpp/header/csignal

I realize that these are all symbolic values and it may be considered poor form to depend on them being specific values (though it can be useful), but this must be here for a reason.

This is a bit upsetting to see because it seems to be there for portability reasons, but at the same time it looks like using it reduces code portability since it's only defined in the UCRT.

sbseltzer
  • 164
  • 7
  • The idea that one value is "portable" and the other is "non-portable" is mistaken. The numeric values, except perhaps the universally-known "9" which is a de facto standard, are not anything that portable or even non-portable programs rely on across platforms. If you want to use a signal, you use the `SIG*` macro names, not the numbers. So this doesn't matter. I'm not sure what the MS justification for having the `_COMPAT` one is, though. – R.. GitHub STOP HELPING ICE Feb 19 '19 at 15:49
  • The one place the numbers themselves are useful is when determining reasons for involuntary shutdown. The numbers for several of them (including SIGABRT) are defined by POSIX, so they're pretty reliable, but it's absolutely true (and I do note it) that the symbolic values should be used. – sbseltzer Feb 19 '19 at 16:38
  • Indeed, I wasn't aware but POSIX *does* define some numbers, for the [`kill` command](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/kill.html). I don't see where this imposes a requirement on the C interface though; it's possible that the numbers the `kill` command accepts differ from the numbers used in the C interfaces. – R.. GitHub STOP HELPING ICE Feb 19 '19 at 17:48

0 Answers0