Marcello has asked for the wisdom of the Perl Monks concerning the following question:
This runs perfectly forever, without every stopping (check_start and check_run fork off child processes if needed to do some work). To clean up zombie processes, I added the following code:while (1) { $self->check_start(); $self->check_run(); # Sleep 1/10 second select(undef, undef, undef, 0.1); }
Since then, my parent process is being killed every now and then (check_start and check_run were left unchanged)$SIG{CHLD} = \&reaper; while (1) { $self->check_start(); $self->check_run(); # Sleep 1/10 second select(undef, undef, undef, 0.1); } sub reaper { my $pid; do { $pid = waitpid(-1, &WNOHANG); } while ($pid > 0); $SIG{CHLD} = \&reaper; }
Title change per author's request - dvergin 2002-04-23
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Determining proces
by Elian (Parson) on Apr 23, 2002 at 19:15 UTC | |
by Marcello (Hermit) on Apr 23, 2002 at 19:20 UTC | |
by samtregar (Abbot) on Apr 23, 2002 at 19:26 UTC | |
by Elian (Parson) on Apr 23, 2002 at 19:28 UTC | |
|
Re: Determining proces
by perlplexer (Hermit) on Apr 23, 2002 at 19:29 UTC | |
|
Re: Determining proces
by Fletch (Bishop) on Apr 23, 2002 at 19:02 UTC |