wait() function...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers wait() function...
# 1  
Old 10-03-2010
wait() function...

when wait() is called by process it blocks calling process until child is done. What happens if calling process have multiple children.
What does wait(NULL) function do. Waits until all children are done?
# 2  
Old 10-03-2010
No. To wait for all children:
Code:
If the calling process has SA_NOCLDWAIT set or  has  SIGCHLD
set  to  SIG_IGN,  and  the process has no unwaited children
that were transformed into zombie processes, it  will  block
until  all  of  its children terminate, and wait() will fail
and set errno to ECHILD.

Having a NULL argument segfaults. Never tried it personally.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Function - Make your function return an exit status

Hi All, Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition. #Body function1() { if then echo "exist" else echo "not exist" } #if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies

2. Shell Programming and Scripting

Will files, creaetd in one function of the same script will be recognized in another function?

Dear All. I have a script, which process files one by one. In the script I have two functions. one sftp files to different server the other from existing file create file with different name. My question is: Will sftp function recognize files names , which are created in another... (1 Reply)
Discussion started by: digioleg54
1 Replies

3. 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

4. Shell Programming and Scripting

wait example

Hi Gurus, Some questions regarding wait. I have tried searching in this forum for threads on wait but not completely got what I am looking for. Background: One script (.sh) that starts/calls a reference to an application's executable and submits a batch job to it. Objective is to wait... (2 Replies)
Discussion started by: rsheikh
2 Replies

5. Shell Programming and Scripting

Wait function in a script

Hi everyone, I need some help to create a script. This script have to create a file once all the process inside are finish. Here how I want to do : #!/bin/ksh /home/oracle/save1.ksh & proc_id1=$! /home/oracle/save2.ksh & proc_id2=$! /home/oracle/save3.ksh & proc_id3=$! ... (4 Replies)
Discussion started by: remfleyf
4 Replies

6. Shell Programming and Scripting

race condition with wait() function

Hi, I'm currently writing a bash script, that starts multiple threads: ____________________ #!/bin/bash loop=0 while((loop!=10)) do thread & ((loop++)) done #wait for all sub-processes (thread) to finish wait ___________________ Now I want to know, what happens, if a... (2 Replies)
Discussion started by: tho99
2 Replies

7. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies

8. 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

9. UNIX for Dummies Questions & Answers

About wait

Hi everyone I'm novice at Unix programming and I hope to post this thread in the correct place. I have the following doubts: 1 Suppose we have some processes which are B's children process and another process A which has no relation with B and its children. Can A do wait () for a... (5 Replies)
Discussion started by: Puntino
5 Replies

10. 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
Login or Register to Ask a Question