Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The unix documentation I have read says you can call waitpid with a negitive pid to wait on an entire process group. However, the perl docs for the function of the same name don't mention this.
The following program tests this out:
Unfortunately it doesn't seem to work on my system (perl 5.6, Tru64). The parent process exits, without waiting for the grandchild process. Is there another way of waiting on a process group?use strict; if (my $pid = fork) { # parent setpgrp($pid, $pid); waitpid($pid, 0); while (waitpid(-$pid, 0) != -1) {} exit; } else { # child if (!(my $pid = fork)) { # grandchild sleep(1) while 1; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: waiting on a process group
by kschwab (Vicar) on Jul 02, 2001 at 02:40 UTC | |
|
Re: waiting on a process group
by Anonymous Monk on Jul 02, 2001 at 02:57 UTC |