I'm reading Kerrisk's book and see that the following as a note,
Caution is required when using a cast integer as the return value of a thread’s start function. The reason for this is that
PTHREAD_CANCELED
, the value returned when a thread is canceled (see Chapter 32), is usually some implementation-defined integer value cast tovoid *
. If a thread’s start function returns the same integer value, then, to another thread that is doing apthread_join()
, it will wrongly appear that the thread was canceled. In an application that employs thread cancellation and chooses to return cast integer values from a thread’s start functions, we must ensure that a normally terminating thread does not return an integer whose value matchesPTHREAD_CANCELED
on that Pthreads implementation. A portable application would need to ensure that normally terminating threads don’t return integer values that matchPTHREAD_CANCELED
on any of the implementations on which the application is to run.
I don't understand importance of the note. Could you codify(show its simple code snippet) it simply to illustrate? What is the issue in th(ese)is case(s)?