The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
msgrcv crash in AIX 5.3 SP6 sandhya_chp AIX 0 06-02-2008 11:54 PM
msgrcv : Invalid argument answers UNIX for Dummies Questions & Answers 1 02-08-2008 06:31 AM
how can i make sar command run forever ? umen UNIX for Dummies Questions & Answers 5 01-30-2008 05:23 AM
user password forever xramm SUN Solaris 5 08-29-2007 01:26 AM
AIX 4.3.3 takes forever to log in Jwoollard AIX 3 03-14-2005 03:56 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-01-2006
Registered User
 

Join Date: Jan 2006
Posts: 1
Stumble this Post!
Angry msgrcv pending forever !!!

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.

Is there any one know that?

Thank you very much.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-01-2006
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 923
Stumble this Post!
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.
Reply With Quote
  #3 (permalink)  
Old 01-02-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,323
Stumble this Post!
I believe that the OP is looking to return from the msgrcv call if there is no message on the queue. Check the man page of msgrcv here.

Quote:
The msgflg argument asserts none, one or more (or-ing them) of the following flags:
IPC_NOWAIT For immediate return if no message of the requested type is on the queue. The system call fails with errno set to ENOMSG.
So when calling msgrcv, set the msgflg variable to IPC_NOWAIT.
Reply With Quote
  #4 (permalink)  
Old 01-02-2006
Registered User
 

Join Date: Dec 2005
Posts: 4
Stumble this Post!
use thread

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.

Hav a gud time.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0