The abort
function in C is supposed to raise a SIGABRT
signal. But what if the underlying platform does not support the SIGABRT
signal or does not support signals at all, for example, when C is ported to some non-Posix-compliant OSes. In this case, what should the implementer do?
Asked
Active
Viewed 50 times
1

John Z. Li
- 1,893
- 2
- 12
- 19
-
It depends on the platform. `abort` probably should terminate the program one way or another. – Jabberwocky Apr 27 '22 at 12:01
-
1If I needed to implement it, I would use setjmp/longjmp in the runtime startup code. – wildplasser Apr 27 '22 at 19:04
1 Answers
1
Fairly simple, in fact. In that case, the implementer of the C runtime needs to make sure that SIGABRT
is delivered to signal
, without help from the OS. It's purely inside a single process.

MSalters
- 173,980
- 10
- 155
- 350
-
2what do you mean by "delivered to signal" if the OS does not support signals? – John Z. Li Apr 27 '22 at 12:07
-
2@JohnZ.Li Function `signal` is part of the C standard library. There is no support by the OS required by the C standard. If you raise a signal, the C library has all it needs to find the callback registered with `signal` function. – Gerhardh Apr 27 '22 at 12:41