Thread: Fork => zombie => error

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    4

    Fork => zombie => error

    Code:
    pid = fork();
    		if (pid < 0){ error("Error: Cannot create new proces"); return EXIT_FAILURE;}
    		if (pid == 0)  {
    			i++;
    			close(sockfd);
    			dostuff(newsockfd,i+pid);
    			close(newsockfd);
    			return EXIT_SUCCESS;
    		}
    Now the problem is that if this process runs for a week or so it has forked so many times that the ps aux list is full of zombies.

    I used to know how to deal with zombies but i seem to have forgotten it. Please help me. The parent doen't need any information of the child when te child ends? So how do I prevent that the child turn into a zombie after the child dies.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You might not need any information, but you still have to call one of the wait() functions to cause the zombie to finally disappear from the process table.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM