When I am using msgrcv to get a message from a queue, in case of msgsnd some error, the msgrcv thread will waiting forever.
Is there some way that I can specify a time out value for this queue ? just let msgrcv wait for some time, if no message comes during this time slot, msgrcv just return failure.
Checking it's manpage, I see one possible return value for it being 'EINTR -- while the process was sleeping to recieve a message, the process caught a signal.' So alarm() might be useful, if it'll cause it to return EINTR instead of killing the process.
Hi, Create a thread to receive (msgrcv) the response.
Wait for certain time (letus say 5sec).
Send a reply (msgsnd) if and only if a flag is set to Success within this thread, after that much wait time.