![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | 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 |
| Can a child process return a specific value to a parent process ? | Ametis1970 | High Level Programming | 8 | 04-09-2008 08:22 PM |
| about child process | compbug | UNIX for Dummies Questions & Answers | 12 | 03-22-2006 03:55 PM |
| gdb to child process | shriashishpatil | UNIX for Advanced & Expert Users | 4 | 12-12-2005 03:57 AM |
| KDM child process | larryase | UNIX for Dummies Questions & Answers | 6 | 01-24-2005 01:41 PM |
| Child Process PID | skannan | High Level Programming | 2 | 06-10-2002 04:54 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
How to Join with child process?
Java and perl have a join feature that allows the main thread to block until a child thread is finished.
Is there a similar feature in (1) bash and (2) perl that will allow the main process to block until the child process is complete? Thanks, Siegfried |
| Forum Sponsor | ||
|
|
|
|||
|
How to wait on multiple child processes?
Let us say I want to create five child processes while the parent process waits until they are all done.
(1) Normally I create a child process with the "&". How do I get the pid? Do I have to parse the "ps" command with perl or awk? (2) How do I specify multiple child processes? I tried "info wait" and "man wait" with no luck. I also tried "info bash" and "man bash" and still no luck. However, I see that my distro does implement wait. Apparently it takes a single integer. I tried "sleep 40&" and "sleep 30&" and "ps" and "wait 6088 5966" and that almost worked. It came back and said "pid 5956 is not a child of this shell after waiting for 6088". I'm checking my work. wait wants the first column of ps labeled "PID", correct? Sieg |
|
|||
|
How to wait for logical "OR"
Since my info/man pages are incomplete, I am assuming wait implements a logical "AND" allowing my parent process to sleep until all the children have died.
(1) How would I implement an "OR" wait where the parent waits for the first child to die, examine the return status code of that child, and possibly spawn a new child to take its place? The children will all be running perl. (2a) I've tried writing synchronous perl children use various integer values for exit function, but I cannot figure out how to detect the exit values in bash. How is this done for a synchronous child? (2b) How do I detect the return status code for an asynchronous child when the parent is blocking on multiple children wait for the first to die? Thanks much! Siegfried |
|||
| Google UNIX.COM |