Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

32. Threads: Thread Cancellation > Canceling a Thread

Canceling a Thread

The pthread_cancel() function sends a cancellation request to the specified thread.

#include <pthread.h>

int pthread_cancel (pthread_t thread);

Note

Returns 0 on success, or a positive error number on error

Having made the cancellation request, pthread_cancel() returns immediately; that is, it doesn’t wait for the target thread to terminate.

Precisely what happens to the target thread, and when it happens, depends on that thread’s cancellation state and type, as described in the next section.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint