PreviousNext

Asynchronous Cancel Safety

A function is said to be asynchronous cancel safe if it is written in such a way that entering the function with the cancelability state of asynchronous will not cause any invariants to be violated if cancellation should occur at any (arbitrary) instruction. Such functions are often written in such a manner that they need acquire no resources, and variables which they write that are visible outside their process are strictly limited.

Any routines that acquire a resource can not be made asynchronous safe. This unfortunately includes most routines that do useful work. The only function that is guaranteed to be asynchronous cancel safe is pthread_cancel( ). In general, no other library functions should be called with cancelability state set to asynchronous.