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
in.timed log entries hcclnoodles SUN Solaris 1 12-04-2006 10:40 AM
Need to execute 2 scripts, wait, execute 2 more wait, till end of file halo98 Shell Programming and Scripting 1 08-01-2006 01:42 PM
timed commands rayne UNIX for Dummies Questions & Answers 2 11-10-2005 01:57 PM
How to Get Timed Input using cin uxbala High Level Programming 5 02-23-2005 08:43 AM
Connection Timed out s_aamir UNIX for Advanced & Expert Users 2 11-20-2002 02:16 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-29-2007
Registered User
 

Join Date: Jun 2007
Posts: 5
Timed wait?

Is there any way in which I can make my wait signal to wait for a specified time for child job to complete. And if that time is over, the program gets out of the wait signal to process other things
Reply With Quote
Forum Sponsor
  #2  
Old 06-29-2007
Registered User
 

Join Date: Jun 2007
Posts: 5
Timed wait?

Is there any way in which I can make my wait signal to wait for a specified time for child job to complete. And if that time is over, the program gets out of the wait signal to process other things, even if the child job is not complete
Reply With Quote
  #3  
Old 06-29-2007
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
Please do not duplicate your posts. That is against the rules.

Now on to your post. There is no call in Linux which does something like that. Win32 API's has something on those lines viz WaitForMultipleObjects.

You can try to simulate something like that. After forking the child, the parent can try sleeping for some amount of time.

You may also want to use the WNOHANG flag so that the execution is not suspended if the child's status is not available immediately.

Last edited by vino; 06-29-2007 at 03:54 AM.
Reply With Quote
  #4  
Old 06-29-2007
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,327
You could combine both of vino's suggestions and have a loop where you wait with WNOHANG and then sleep for a second. Have a counter to achieve your timeout condition.

This might be wasteful of CPU though.
Reply With Quote
  #5  
Old 06-29-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by blowtorch View Post
This might be wasteful of CPU though.
Or set an alarm then do a blocking wait.

If you did not know, all wait does, if there are no zombies to reap, is wait for a SIGCLD signal from one of it's children, You could wait for that signal explicitly.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:16 PM.


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

Content Relevant URLs by vBSEO 3.2.0