Home > Archive > Unix Programming > April 2007 > Re: when parent process keeps forking child but doesnot wait...
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: when parent process keeps forking child but doesnot wait...
|
|
| Bin Chen 2007-04-24, 7:05 pm |
| On 4=D4=C224=C8=D5, =CF=C2=CE=E712=CA=B116=B7=D6, djh...@gmail.com wrote:
> Hi Unix guru,
>
> In my case, parent receives a request and forks itself and lets the
> child perform a task.
> But parent doesnot wait for child to complete and exit.
> This kind of behavior is normal ,right?
>
> But, when I ps , looks like it displays all those completed and
> exited child processes-->which is bothering me. Do I need to worry
> about it?
Yes, zombie does not consume any resource except some bookkeeping info.
| |
| Jens Thoms Toerring 2007-04-25, 10:03 pm |
| Bin Chen <binary.chen@gmail.com> wrote:
> On 4?24?, ??12?16?, djh...@gmail.com wrote:
[color=darkred]
> Yes, zombie does not consume any resource except some bookkeeping info.
They consume at least one slot in the process table and since
normally there's only a limited number of proceses you can have
at any time (alive or zombies) it's prudent to have them go away,
espcially if the parent is a long-lived program that fork()s a
lot. And it's easy with waitpid() if you call from time to time
while ( waitpid( -1, NULL, NOHANG ) > 0 )
/* empty */ ;
this removes all zombies that exist at that moment and should
consume much time.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
|
|
|
|
|