I've found the solution for the previous problem, but there is another one.
But for this, I didn't find any fix yet.
The code:
[...]
use HTTP::Daemon
use Parallel::ForkManager;
PM with , for example 3 processes MAX
[...]
while (1)
{
$inputcon = $daemon->accept();
$pm->start and next; #fork
do_client_stuff($inputcon);
$pm->finish();
}
When I doing wgets on this script all is working OK, I see the children on the processes list but there is a problem with last (always with last)
The last child process stays as zombie, always. When I do one wget more, this zombie process exits normally and another (this one from this current wget query) becomes a zombie
5989 pts/5 S+ 0:00 \_ grep test.pl
5975 pts/4 S+ 0:00 \_ /usr/bin/perl ./test.pl
5987 pts/4 Z+ 0:00 \_ [test.pl] <defunct>
You know, last child process is always a zombie. Don't know why all processes are working OK, but the last is not.
Any hint, solution?
Thank you.
// sorry for my english
Here is the sample code. One wget on 127:8080 makes the child process is a zombie. But script is working, new query / new zombie PID.
#!/usr/bin/perl
use HTTP::Daemon;
use Parallel::ForkManager;
$daemon = new HTTP::Daemon(LocalPort => 8080, LocalAddr => "127.0.0.1", Listen => 64, ReuseAddr => 1) or die "$!";
$pm = Parallel::ForkManager->new(3);
while (1)
{
$inputcon = $daemon->accept();
$pm->start and next;
do_client_stuff($inputcon);
$pm->finish();
}
sub do_client_stuff
{
my ($inputcon) = @_;
$request = $inputcon->get_request;
print $request . "\n";
$inputcon->send_error(403);
}