Is there a way to halt execution, somewhat like SIG_ABRT, but immediately, even if we're not on the main thread?
Core Foundation has a macro HALT that should do the trick, if you really, really think it's necessary to do this:
#if defined(__ppc__)
#define HALT do {asm __volatile__("trap"); kill(getpid(), 9); } while (0)
#elif defined(__i386__) || defined(__x86_64__)
#if defined(__GNUC__)
#define HALT do {asm __volatile__("int3"); kill(getpid(), 9); } while (0)
#elif defined(_MSC_VER)
#define HALT do { DebugBreak(); abort(); } while (0)
#else
#error Compiler not supported
#endif
#endif
#if defined(__arm__)
#define HALT do {asm __volatile__("bkpt 0xCF"); kill(getpid(), 9); } while (0)
#endif
If you're using a Macintosh app, "[[NSApp sharedApplication] terminate: self]" will work.
On an iPhone, you can even do "exit(-1)", but Apple will NOT accept any apps that abruptly or in any way terminate other than the user killing the app themselves. Here is a related question with some useful answers for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With