Zombies and Multiprocessor???

This is a discussion on Zombies and Multiprocessor??? within the Linux Programming forums, part of the Platform Specific Boards category; I am having a problem with fork() and the child processes becoming zombies. I am using the code from the ...

  1. #1
    Registered User 3dkiwi's Avatar
    Join Date
    Dec 2006
    Posts
    4

    Zombies and Multiprocessor???

    I am having a problem with fork() and the child processes becoming zombies.

    I am using the code from the Advanced Linux Programming book that sets up a simple
    web server that forks child processes to handle requests. This is all working OK but
    when the child processes complete they are not being cleared correctly by the
    signal handler clean up function that calls the wait() function.

    I am wondering if there is anything that needs to be done beyond the code from
    the book if this program is running on a Dual Processor machine?

    Cheers in advance
    Jim

  2. #2
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    I have always had to use waitpid() to get the zombies gone.

  3. #3
    Registered User 3dkiwi's Avatar
    Join Date
    Dec 2006
    Posts
    4

    Re: Zombies and Multiprocessor???

    Kennedy

    Just rechecked, and yes I am using wait() so will try waitpid() and get back to you.

    Need to do some more readup on this call to make sure it does not break other things.

    Thanks for the prompt reply.

    Cheers
    Jim

  4. #4
    Registered User 3dkiwi's Avatar
    Join Date
    Dec 2006
    Posts
    4

    Fixed

    Kennedy

    Tnx for that.

    I changed the wait(&status) to waitpid((pid_t)-1, &status, 0) and seems to be working like a charm.

    Once I have finished off some details I will publish what I was doing at:

    http://www.pyenet.co.nz/legrob/index.html

    Cheers
    Jim

  5. #5
    Registered User 3dkiwi's Avatar
    Join Date
    Dec 2006
    Posts
    4

    Not quite fixed but published

    After letting the process run for a while longer it seems that the Zombie issue is not resolved correctly.

    However I now have finished my webpage on the information for the Parallel Port Interface I constructed. Check out:

    http://www.pyenet.co.nz/legrob/paral...interface.html

    Cheers
    3d

  6. #6
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Looks to me like you are missing some of the processes. . . pid_t would be a process number???? if so, then you are looking for the process number pid_t - 1, which wouldn't be the pid_t. . . If you want to clean up ANY zombie, you'd send -1 in stead of pid_t - 1, however, this would not tell you which process has ended. Here is a chunk from the man page:
    Code:
           The value of pid can be one of:
    
           < -1   which means to wait for any child process whose process group ID is equal to the absolute  value
                  of pid.
    
           -1     which means to wait for any child process; this is the same behaviour which wait exhibits.
    
           0      which means to wait for any child process whose process group ID is equal to that of the calling
                  process.
    
           > 0    which means to wait for the child whose process ID is equal to the value of pid.
    Hope this helps! (BTW, from what I can recall [and it has been 10+ years] the process waitpid(-1, NULL, WNOHANG) would clean up all children that have returned).

Popular pages Recent additions subscribe to a feed

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