LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   parent process to wait foe child process to comelet (https://www.linuxquestions.org/questions/linux-kernel-70/parent-process-to-wait-foe-child-process-to-comelet-932086/)

priyas 03-01-2012 12:38 AM

parent process to wait foe child process to comelet
 
Hi all,
I am new to unix and need some help.
I have two scripts lets say A.expect and B.sh needs to be executed.
I am executing B.sh from A.expect where B.sh has sleep command.
My problem is that when B.sh encounters the sleep command my A.expect starts executing and exits.
but my A.expect should execute only after completing B.sh.
Is there any solution to this problem without using sleep command in A.expect.
Thanks in advance.

corp769 03-01-2012 04:48 AM

After briefly reading over your post, what you would want to use is the wait command. Have a look at the man page, and an example:
http://linux.die.net/man/2/wait
http://stackoverflow.com/questions/2...hild-processes

I would describe more precisely how to use it, but you did not provide us with your scripts. If you provide us with the needed information, then we will be able to better assist you.

Cheers,

Josh

sundialsvcs 03-01-2012 08:52 AM

It might even be simpler. Read carefully man bash. (I said, carefully.)

Normally, when you execute a series of commands, bash will wait for that process to terminate before proceeding, although it provides the & suffix to allow for parallel execution. Normally, bash forks the child process, then goes to sleep waiting for it to finish so that it can reap the child and collect its ending status. If that's not happening for you, please provide us with an appropriate excerpt of your actual script.


All times are GMT -5. The time now is 05:33 AM.