Defunct processes after fork()

Hi,

I have written a C program on Unix, which uses fork(), and it's doing something unexpected!!

The child process created handles an incoming connection to a socket, then exits, while the parent waits for another request. I've noticed though that a 'ps' command shows a set of processes called , one for each time a child has been created and exited.

Can anyone tell me how I can stop this, or if I even need to worry about it (If I kill the parent, all the processes disappear.

Thanks in advance.

Comments

  • : Hi,
    :
    : I have written a C program on Unix, which uses fork(), and it's doing something unexpected!!
    :
    : The child process created handles an incoming connection to a socket, then exits, while the parent waits for another request. I've noticed though that a 'ps' command shows a set of processes called , one for each time a child has been created and exited.
    :
    : Can anyone tell me how I can stop this, or if I even need to worry about it (If I kill the parent, all the processes disappear.
    :
    : Thanks in advance.
    :

    you need to either have the parent process ignore the SIGCLD signal or have it wait() or waitpid() for the children to die. Otherwise there remains some stuff for the parent to pick up (like the return value of the child) so the child shows up as in ps.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion