The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-29-2007
anjul_thegreat anjul_thegreat is offline
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
  #2 (permalink)  
Old 06-29-2007
anjul_thegreat anjul_thegreat is offline
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
  #3 (permalink)  
Old 06-29-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
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 07:54 AM..
  #4 (permalink)  
Old 06-29-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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.
  #5 (permalink)  
Old 06-29-2007
porter porter is offline Forum Advisor  
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0