Reputation: 1857
I'm using Cygwin
to compile my C programs
I created a program that will call abort
whenever an error occurs.
when I run the program from Cygwin Terminal
the function produces the following output:
Aborted (core dumped)
but If I run the program from Windows CMD or Explorer it produces the following:
0 [main] test 1904 cygwin_exception::open_stackdumpfile: Dumping stack trace to test.exe.stackdump
Can I change the message to the first format? How?
because the second format is very ugly and I can't tell if this is a bug in the program (e.g: Access Violation, Divide By Zero,...) or the abort
function>
and why do I get different messages even though the build is the same?
Note: Please, Don't tell me not to use the abort
function or the Cygwin compiler
Upvotes: 1
Views: 936
Reputation: 36327
The point is that the output you're seeing comes from the Cygwin standard library. You will either need to modify that (don't worry, it's surely open source).
It seems that the cygwin terminal environment has a way of handling with such exceptions in a manner that doesn't cause the string you don't want to be printed. So, since abort should really not be overly user-configurable, you'll have to modify the way SIGABRTs are handled by the cygwin libc.
Thus, you've excluded the only answer that seems correct: Don't use stock cygwin, or don't use abort
. Generally, you can't rely on what abort
gives on your console, since this definitely isn't defined behaviour, can change with localizations, and is generally a bad way of handing error codes out of your applications. The old-school unix way of doing this is return codes, so I recommend using them.
Upvotes: 1