Merge pull request #257 from tkchia/tkchia/abort
libcc.ansi: make abort() try harder to abort the process
This commit is contained in:
		
						commit
						bca0a5381d
					
				
					 1 changed files with 18 additions and 1 deletions
				
			
		|  | @ -1,14 +1,31 @@ | ||||||
| /*
 | /*
 | ||||||
|  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. |  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. | ||||||
|  * See the copyright notice in the ACK home directory, in the file "Copyright". |  * See the copyright notice in the ACK home directory, in the file "Copyright". | ||||||
|  |  * | ||||||
|  |  * (c) copyright 2022 by TK Chia. | ||||||
|  */ |  */ | ||||||
| /* $Id$ */ | /* $Id$ */ | ||||||
| 
 | 
 | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
| #include <signal.h> | #include <signal.h> | ||||||
|  | #include <unistd.h> | ||||||
| 
 | 
 | ||||||
| void abort(void) | void abort(void) | ||||||
| { | { | ||||||
|  | 	unsigned short count = 0; | ||||||
|  | 	int *bad_ptr = NULL; | ||||||
|  | 	while (--count != 0) | ||||||
| 		raise(SIGABRT); | 		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); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue