Next: , Previous: Standard I/O, Up: libnix.a

6.4.6 Signal handling

There is only support for the two signals SIGABRT and SIGINT. The library knows of some other signals but cannot generate them. The support for SIGABRT is simple - but SIGINT is a completely different thing:

You cannot use exec signal handlers since they are called at any time - even in the middle of a library call. And if your library just blocked a private semaphore and you jump out of the library code you will get a nice deadlock :-(. (And for people who don't know: signal handlers are bogus upto OS 2.0 (even there you need a good setpatch)).

So SIGINT (CTRL-C) is just polled at the start of most I/O-functions by calling the function

void __chkabort(void)

Other signals are even more difficult to implement:

You can disable CTRL-C handling by replacing ‘__chkabort’ with a do-nothing stub function - but there is a better way. Just call


Replacing __chkabort is used very often by amiga-programs and if your application does not need CTRL-C handling at all and is amiga specific you can use this. The second method is the ANSI standard method and works on all types of machines.