in reply to Child PID?

Erh, fork already returns the child's pid (to the parent, if succesful). There is absolutely no need to increment it. If there is, your operating system is seriously broken.

if (my $pid = fork) { # parent } elsif (defined $pid) { # child exit; } else { # error }

Some style issues: Don't use &foo: use foo() instead. &foo has some unpleasant side effects (passes @_ if you don't use parens. Put subs near the top to avoid sharing _all_ file scoped lexicals. This will be useful when you use strict. Third, use strict. Reasonably important: check the return value of kill. Reaping and killing are not the same, by the way. Use waitpid or wait to reap.

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.

Replies are listed 'Best First'.
Re: Re: Child PID?
by Anonymous Monk on Jun 06, 2002 at 23:47 UTC
    I found out what was wrong. I was launching netscape for the first time and box that asks you a question has a differt PID than when the actual browser is launched. Anyway Im still a little confused about the difference between reaping and killing. In this situation would reaping be better than killing?

      Reaping is generally used to describe the action of terminating zombie processes, which are children that have outlived their parent. Since their parent does not exist to clean up after the child, the kernel's process table retains the defunct child. Such zombies must be reaped.

      Killing a process is a more general term used to describe the act of terminating an active process.

      If you are trying to automate the response to a dialog box, that's different. Just killing it could be bad.


        Note that in the program given, no zombies will be created as the handler for SIGCHLD is set to 'IGNORE' (which is the default on many OSses anyway).

        Abigail