Merge pull request #257 from tkchia/tkchia/abort

libcc.ansi: make abort() try harder to abort the process
This commit is contained in:
David Given 2022-07-16 13:55:22 +02:00 committed by GitHub
commit bca0a5381d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,14 +1,31 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*
* (c) copyright 2022 by TK Chia.
*/
/* $Id$ */
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
void abort(void)
{
raise(SIGABRT);
unsigned short count = 0;
int *bad_ptr = NULL;
while (--count != 0)
raise(SIGABRT);
/*
* If the target platform does not implement raise(.), or the
* SIGABRT signal turns out to be handled or ignored, then our
* process may still be running. Try harder to make the process
* crash or exit. -- tkchia
*/
while (--count != 0)
abs(*bad_ptr);
write(2, "abort!\n", 7);
for (;;)
_exit(128 + SIGABRT);
}