![]() |
|
|
|||||||
| Home | Forums | Register | Rules & FAQ | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
Other UNIX.COM Threads You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Launching Several Shells.... | marconi | Shell Programming and Scripting | 1 | 03-05-2008 03:24 PM |
| different kinds of shells | gurujoe | Shell Programming and Scripting | 3 | 02-28-2008 06:28 AM |
| Changing Shells on IBM AIX | clairepst | AIX | 3 | 05-30-2007 01:45 AM |
| How to open multiple shells while the scripts keeps running. | Closed_Socket | UNIX for Dummies Questions & Answers | 5 | 10-08-2006 07:06 AM |
| Shells | dino_leix | UNIX for Advanced & Expert Users | 3 | 06-08-2005 03:07 AM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
| Forum Sponsor | ||
|
|
|
|||
|
Hello,
You are getting zombies, because the child from childpids[0] isn't killed. See in while(--count) : When count is 1 -> --count gives 0 and loop exits. The program "forget" to kill first child and when the father program closes, that child becomes a zombie. You can replace the while loop with: for(count-=1; count >= 0; count--) { ... or something equivalent. A note, I see you use vfork() for creating childrens.... which will always work fine in your example. However, its behaviour will become undefined when you will call other functions than execl after the fork, or modify other variables. Fork() would be safer for programs which are not using execl. Hope it helps. Best regards. |
|
|||
|
I'm rewriting my post... It seems it got lost somehow.
Check the line while(--count). The "While" loop will exit when count is 1, as --count is evaluated to 0, so the child from childpids[0] isn't killed. You can simply replace the "while" line with: for(count-=1; count >= 0; count--) Best regards! |
|
|||
|
That's not going to be a terrifically useful enterprise without giving the shells the environment they expect. See man forkpty if on linux/*BSD.
Also you could handle child exits asynchronously by using waitpid in a handler for SIGCHLD and avoid your zombie woes. An example: rmathew: Terminal Sickness HTH |
|||
| Google UNIX.COM |