I am working on a pthread multi-threaded code and each thread is calling read() on a file descriptor. read() is a blocking call so it waits for data. But i want it to wait only for 3 secs to wait for data.
I thought of using alarm() and hadling SIGALRM but if I raise alarm in one thread, all the threads will got that SIGALRM signal and all of them will relinquish read. How can i do it?