![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| suspend a process | superuser84 | UNIX for Advanced & Expert Users | 6 | 03-18-2008 06:36 PM |
| Suspend Cron job temprory | pankajkrmishra | Shell Programming and Scripting | 4 | 08-14-2006 05:18 AM |
| suspend/restart a process in shell script | daneensign | Shell Programming and Scripting | 1 | 02-13-2006 09:43 PM |
| Suspend to write file | ust | UNIX for Advanced & Expert Users | 3 | 12-13-2005 01:56 AM |
| UNIX Process Suspend | proton | UNIX for Dummies Questions & Answers | 3 | 02-13-2005 12:27 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello,
Two child processes work at the same time because they communicate one another. In KSH, does it exist a good way to suspend a parent process until one of the two child processes stops. It seems that the command 'wait' works well for one process but for two processes, it suspends the parent process until all the background child processes stop. If a command or a C-code could return a status as well, that will be more better. thanks Last edited by piou78; 05-29-2005 at 10:57 AM. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
You can use pipes for this
So you have two child processes and one parent process.
Create a pipe and have a "write to pipe" in each of the child processes as the last statement in the child process. and you have only one "read from pipe" in the parent process. so whichever child completes first, it will write to the pipe and the parent process will finish the read immediately. |
|
#3
|
|||
|
|||
|
How about using signal?
Would it be convenient that both child processes send a SIGUSR1 to the parent before end and that the parent has a sig handler which terminates itself? Tom |
|
#4
|
|||
|
|||
|
#!/bin/ksh
start_first_child.sh & start_second_child.sh & while [ $(jobs | wc -l) -gt 0 ] ; do sleep 1 done exit 0 Hope this helps bakunin |
|
#5
|
|||
|
|||
|
Quote:
Thanks for the reply but I don't undertand what you mean by "write to pipe" or "read from pipe". Could you give me a practical example, please? Thanks |
|
#6
|
|||
|
|||
|
Quote:
|
|
#7
|
|||
|
|||
|
Quote:
|
|||
| Google The UNIX and Linux Forums |