Timed wait?


 
Thread Tools Search this Thread
Top Forums Programming Timed wait?
# 1  
Old 06-29-2007
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  
Old 06-29-2007
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  
Old 06-29-2007
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 08:54 AM..
# 4  
Old 06-29-2007
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  
Old 06-29-2007
Quote:
Originally Posted by blowtorch
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

calling a shell script in background and wait using "wait" in while loop

Hi, I am facing a strange issue, when i call a script from my while loop in background it doesnt go in background, despite the wait i put below the whil loop it goes forward even before the process put in background is completed. cat abc.txt | while read -u4 line do #if line contains #... (2 Replies)
Discussion started by: mihirvora16
2 Replies

2. Shell Programming and Scripting

timed kill within script?

I want to warn everyone, I am not a programmer lol. I'm an IT wanting to get a little insight of programming, and I like to play around so I can learn. Ok, so I'm going to school for IT Security and Forensics. I had a project to write a hack, and I chose to write a shell script to run dd to write... (8 Replies)
Discussion started by: joshbgosh10592
8 Replies

3. Shell Programming and Scripting

Timed Scripts

Hi all I need a little bit of help, i am looking for a script that can have different events in it and then if it is a certain day email me about it some sort of email reminder system any ideas thanks (4 Replies)
Discussion started by: ab52
4 Replies

4. Solaris

I/O timed out

I have Ultra 45 Sun solaris box with Solaris 10 installed. My problem is when i boot the unix box, i got the message: What does this message meant? then it does not continue to boot successfully. Please help. Thanks in advance. (5 Replies)
Discussion started by: etcpasswd
5 Replies

5. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies

6. UNIX for Dummies Questions & Answers

Timed read command

Hi guys, I love unix....but i also hate it :) I want to write a script that will pause in the middle ask for user input, but if no input is given i want the script to continue anyway. Say ask a question and give 1 min to answer and if no answer at all the script continues. (2 Replies)
Discussion started by: Noob e
2 Replies

7. HP-UX

connection timed out

I am trying to connect with my hp machine using "dialup networking." It times out after 30 seconds. Is there a way to adjust this time. Would it have anything to do with rexec? thanks (0 Replies)
Discussion started by: paschal
0 Replies

8. Shell Programming and Scripting

Need to execute 2 scripts, wait, execute 2 more wait, till end of file

:cool: I need to execute a shell script to do the following: cat a file run two back ground processes using the first two values from the file wait till those background processes finish run two more background processes using the next two values from the file wait till those background... (1 Reply)
Discussion started by: halo98
1 Replies

9. UNIX for Dummies Questions & Answers

timed commands

Hello, How can I set up events to be executed at a certain time? And do I need some kind of privilege such as being in cron group? (2 Replies)
Discussion started by: rayne
2 Replies

10. UNIX for Advanced & Expert Users

Connection Timed out

I connect to a Sun Box through telnet but it timed out in couple of minutes. Advance thanks for any idea...help... (2 Replies)
Discussion started by: s_aamir
2 Replies
Login or Register to Ask a Question