From 80d1932ff8f2149a35c2063f1d6d95b9c99c59a7 Mon Sep 17 00:00:00 2001 From: tkchia Date: Sat, 16 Jul 2022 07:27:46 +0000 Subject: [PATCH] libcc.ansi: make abort() try harder to abort the process --- lang/cem/libcc.ansi/core/misc/abort.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lang/cem/libcc.ansi/core/misc/abort.c b/lang/cem/libcc.ansi/core/misc/abort.c index d59624169..bcf0759c7 100644 --- a/lang/cem/libcc.ansi/core/misc/abort.c +++ b/lang/cem/libcc.ansi/core/misc/abort.c @@ -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 #include #include +#include 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); }