rmascarenhas/lpi — pull request #24 by rmascarenhas (2014-11-04 13:11:24+00:00)
Title: #32 - Threads: Thread Cancellation

This chapter had no exercises, but I came up with an idea of one, just to practice the concept of the chapter.

It spawns a worker thread that will calculate Fibonacci numbers (with no cancellation point) and explicitly call `pthread_testcancel(3)`. If the user decides to interrupt the computation, the cancellation request is sent and we check that the thread was indeed cancelled. However, if the program is compiled with `NOTESTCANCEL` defined, then no test is performed, and we observe that even if the user requests it, the thread is never canceled.