Fork => zombie => error

This is a discussion on Fork => zombie => error within the Linux Programming forums, part of the Platform Specific Boards category; Code: pid = fork(); if (pid < 0){ error("Error: Cannot create new proces"); return EXIT_FAILURE;} if (pid == 0) { ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    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, 03: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, 01:53 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21