Subj : Re: pthread_cancel To : comp.programming.threads From : Giancarlo Niccolai Date : Mon May 09 2005 12:55 pm doug wrote: > "Greg Law" wrote in message > news:2l81pnF9h89tU1@uni-berlin.de... >> Hi, >> >> I am calling pthread_cancel on a thread that has canceling enabled, of >> deferred type. The thread I am canceling never makes any calls to >> testcancel, or waits on any condition variables. So it surprises me that >> the cancelation has any effect at all. That is, in the following program >> the thread I've created is terminated (to my surprise). I guess I've not >> understood correctly when threads may be canceled? >> >> Cheers, >> >> Greg >> > > If I remember correctly, I think POSIX states that certain system calls > (read, write, etc.) are cancellation points. So the printf() in your > Start() routine would be a cancellation point. > What version of OS & threading lib are you using? I know that until > recently, LinuxThreads hand't actually implemented this, though (e.g. see > manpage for pthread_cancel on an older Fedora Core 3 system). It may have > been fixed recently, or may be correct in NPTL. Correct; printf may or may not be a cancellation point depending on the fact that it calls or calls not write() to perform an output to a stream. I don't have news about printf being explicitly declared NOT a cancellation point by posix, so, what happens inside printf is to be considered "random". Giancarlo. .