in reply to Ending Properly

A defunct process on UNIX is one that exits, but has no parent waiting on it to reap the process. So this probably has less to do with your Perl script than with the environment it's started in. Are you trying to background it, have it become a daemon, or running it from cron?

Replies are listed 'Best First'.
Re: Re: Ending Properly
by jasonk (Parson) on Feb 17, 2003 at 18:08 UTC

    Actually a defunct process does have a parent, but the parent has not collected the exit code from the child process. If the parent goes away, the child will be reparented to init, which will collect the exit code and allow the zombie to die.

      Ok. How do I make the parent go away? I'm not using fork or anything like that. All my scripts are designed to run straight from top to bottom. Thanks for your help.
        You really need to give us a better idea of what you are doing. In this case, since you don't appear to be forking off children, I'd suggest giving us some idea of the environment setup, how you are starting up your script, any strange things you might be doing such as backgrounding (as mentioned above). Also, are you using any modules that might be forking under the hood? You're doing the equivalent of asking us to fix your car without telling us the make, model, or circumstances surrounding the breakdown.

        jasonk is correct (my bad): the zombie has a parent that's not waiting for it. Killing the parent and letting init clean it up is not the right thing to do. You need to find out why you have this situation. Even if you're just running scripts straight through, there may be a hidden fork call in a package you're using; or there may be another script invoking yours that's doing something that affects this.

        Can you give us any details on how your scripts are started, what package(s) they're using, and what general processing they're doing?