Subj : Re: Killing threads To : comp.programming.threads From : steve Date : Wed Aug 17 2005 12:13 am In article <43026977.3060905@Lucent.com>, Srini Palthepu wrote: > >>>My application has a set of daemon threads for doing the work >>>that are alocated for each client request. But when a thread hangs in >>>the proces of serving a client for any reason, I need to cleanup. >>>I am trying to kill the hung thread and respawn a new one as a way >>>of cleaning up. >> >> >> This is a thread pool? > >yes. > > >> Why not add the logic to the threads to detect a timed out condition and clean >> up after themselves? >> > >How do a thread that is blocked doing the work >detect timeout? In my case, the main thread gets a >reset request from client upon timeout. >May be I can send an interrup signal instead of >SIGKILL to the thread. You apparently missed my subtle hint. There is a mechanism, known an cancellation, that probably does what you want. But be warned that it's remarkably challenging to use cancellation correctly, and a lot of third-party libraries don't handle it correctly. man pthread_cancel -- Steve Watt KD6GGD PP-ASEL-IA ICBM: 121W 56' 57.8" / 37N 20' 14.9" Internet: steve @ Watt.COM Whois: SW32 Free time? There's no such thing. It just comes in varying prices... .