08-08-2019
Wait till any one child process finishes
Hi
I am facing a problem in my ksh.
My main script is calling 3 different child process in the background.
I am using wait to finish all and then submit another 3 child processes.
Now what i want is , whenever any one child process finishes ,i want to submit next one.so that parallel 3 processes should run all together.
I tried wait -n ,but it did not work in ksh
10 More Discussions You Might Find Interesting
1. Programming
As far as I can tell, the bash wait command waits for a logical "AND" of all the child processes.
Assuming I am coding in C:
(1) What is the function I would use to create multiple bash child process running perl?
(2) What is the function I would use to reinvent the bash wait command so I... (4 Replies)
Discussion started by: siegfried
4 Replies
2. Shell Programming and Scripting
: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
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
Hi All,
I have two ksh script. 1st script calls the 2nd script and the second script calls an 'C' program.
I want 1st script to wait until the 'C' program completes.
I cant able to get the process id for the 'C' program (child process) to make the 1st script to wait for the second... (7 Replies)
Discussion started by: sennidurai
7 Replies
5. UNIX for Dummies Questions & Answers
If I run "sleep 10&".. when that background process is done, is there a way for unix to print to screen to let me know? Thanks. (1 Reply)
Discussion started by: jmelai
1 Replies
6. Shell Programming and Scripting
I am trying to find a list of files and writing it to a text file. Based on the machine performance the file writing will be slow at certain time.
The code to find file and redirecting the output to text file is on a shell script
/usr/bin/find $SEARCH_DIR -daystart \( \( -name 'KI*' -a... (4 Replies)
Discussion started by: nuthalapati
4 Replies
7. Programming
Hello. I want to make a child do some stuff,wait,then the parent does some stuff and then child does some stuff and waits again.I have made the following but it does not work.Can anybody help me?
pid1 = fork();
if (pid1 == -1)
{
perror("Can't create child\n");
... (18 Replies)
Discussion started by: Cuervo
18 Replies
8. Shell Programming and Scripting
Hi everyone
i am very new to linux , working on bash shell.
I am trying to solve the given problem
1. Create a process and then create children using fork
2. Check the Status of the application for successful running.
3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies
9. UNIX for Dummies Questions & Answers
Hello all,
I have a very basic question. I have a requirement where in, I have a main process which forks a child process, which execs and runs a c executable corresponding to a daemon. In the c executable corresponding to a daemon, as everyone does, I fork another child process, and as part of... (7 Replies)
Discussion started by: sai2krishna
7 Replies
10. Shell Programming and Scripting
Hi all,
I am starting mgen5 for sometime depends on input from a file, in a child process. now I want to make parent to wait in this child process till mgen5 finishes, or timeout happens.
could anyone please tell me how to make parent to wait in child process in shell script?
thanks... (2 Replies)
Discussion started by: girijajoshi
2 Replies
WAIT(2) System Calls Manual WAIT(2)
NAME
wait - wait for process to terminate
SYNOPSIS
wait(status)
int *status;
wait(0)
DESCRIPTION
Wait causes its caller to delay until a signal is received or one of its child processes terminates. If any child has died since the last
wait, return is immediate; if there are no children, return is immediate with the error bit set (resp. with a value of -1 returned). The
normal return yields the process ID of the terminated child. In the case of several children several wait calls are needed to learn of all
the deaths.
If (int)status is nonzero, the high byte of the word pointed to receives the low byte of the argument of exit when the child terminated.
The low byte receives the termination status of the process. See signal(2) for a list of termination statuses (signals); 0 status indi-
cates normal termination. A special status (0177) is returned for a stopped process which has not terminated and can be restarted. See
ptrace(2). If the 0200 bit of the termination status is set, a core image of the process was produced by the system.
If the parent process terminates without waiting on its children, the initialization process (process ID = 1) inherits the children.
SEE ALSO
exit(2), fork(2), signal(2)
DIAGNOSTICS
Returns -1 if there are no children not previously waited for.
ASSEMBLER
(wait = 7.)
sys wait
(process ID in r0)
(status in r1)
The high byte of the status is the low byte of r0 in the child at termination.
WAIT(2)