![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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
|
||||
|
||||
|
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. |
|
#4
|
||||
|
||||
|
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
|
|||
|
|||
|
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. |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|