Subj : Linux pthreads, C-program, how to timeout a thread? To : comp.programming.threads From : fj40rockcrawler Date : Wed Apr 27 2005 05:48 pm I've done several searches but can't find anything really specific to what I'm doing. This is the first program I have ever used threads with. The program talks to a serial port with standard Linux read/write function calls. However, those are blocking calls, like the read, it will block until there is something to read. I don't want a broken link to stop the whole program, so I'm using threads. I have a modbus thread and a logic thread. The modbus thread does the actual reading/writing on the serial port and updates a global array of values (using the mutex lock/unlock method, so data integrity is protected). However I would like the read/write functions to basically be in their own thread also (a 'small' thread perhaps, with only that function?), that I could time out. So I could say if the ReadMBThread didn't complete in 100ms I would terminate it and log and error and go on. I have not found anything specific about timing a thread like that. I read up on the TimedWait where you're either waiting on a condition or mutex to become free. I guess I could rig the code up with that, so technically it would be waiting on a mutex, but not really since it's really just waiting on the read/write function to complete, but I could have some mutexs to solve that probably. Any ideas? Can you put a timeout on a thread when you create it? Thanks in advance! Mark Brodis fj40rockcrawler@gmail.com .