in reply to Fork and exec
but when i use fork, it still wait the status of the program.I gather that your parent is hanging someplace where you don't want it to hang. Are you calling wait or waitpid in the parent?
If you don't need the exit status of a child process, you never need to call wait or waitpid or handle SIGCHLD. A 'zombie' process will be created when the child exits, but this is simply the child's entry in the system's process table and doesn't consume any appreciable memory. Zombie entries will be released when the parent exits.
If you want to check if a child has exited without hanging, then call waitpid with the WNOHANG parameter - see perldoc -f waitpid for an example.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Fork and exec
by perlmonkdr (Beadle) on May 01, 2008 at 08:28 UTC | |
by rowdog (Curate) on May 01, 2008 at 22:59 UTC | |
by perlmonkdr (Beadle) on May 02, 2008 at 20:34 UTC |
In Section
Seekers of Perl Wisdom