Subj : Re: pthreads: cancelling thread blocked on berkeley socket accept() To : comp.programming.threads From : David Hopwood Date : Mon Sep 19 2005 07:26 pm Marcin 'Qrczak' Kowalczyk wrote: > David Hopwood writes: > >>You should set a shared 'shouldExit' flag and close() the socket >>from the main thread. The listening thread will get an error from >>the accept(), and can then exit when it sees that 'shouldExit' is >>set. > > I suppose there must be additional memory synchronization because > accept + close don't synchronize memory, right? Technically, yes, although I would be very surprised if any actual implementation failed due to lack of synchronization. At worst, the listener thread would loop, continually getting an error on the accept(), until it saw the shouldExit flag. -- David Hopwood .