Subject: | backticks and explicit fork crash with PreFork(Simple) |
Hi,
I tried to use backticks with Net::Server::PreFork. The script always crashs. So I tested it with fork, exec and waitpid but it crashed too. The interesting thing was that it sometimes failed and sometimes succeed. The successrate was between 40 and 80 percent.
I was ready to give up but then I thought take it small and simple and tested the superclasses PreForkSimple and Fork. Surprisingly PreForkSimple failed too but Fork didn't fail. I checked the code in PreForkSimple and it looks like a problem with the communication between the server and the preforked childs.
I attached a sample script which works with Fork and crashs with PreFork(Simple). I hope this helps a little bit.
Best regards
Michael
perl -v: v5.8.0 built for i586-linux-thread-multi
uname -a: Linux dns_name 2.4.20-4GB #1 Wed Aug 6 18:26:21 UTC 2003 i686 unknown unknown GNU/Linux
use lib '/home/michael/OpenCA/Test/test1/modules/perl5';
use Net::Server::Fork;
use strict qw (@ISA);
package MyServer;
@ISA = qw(Net::Server::Fork);
## activate server
my $pid = fork ();
if (not $pid)
{
MyServer->run (
proto => "unix",
port => "/tmp/server_socket|unix");
}
## test server
sleep 1;
for (my $i=1; $i<11; $i++)
{
client ();
}
kill 15, $pid;
## client activity
sub client
{
use Socket;
## Unix socket
my $socket_name = "/tmp/server_socket";
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die ("Cannot create new client socket ($socket_name).");
connect(SOCK, sockaddr_un($socket_name)) || die ("Server is not online or does not accept requests ($socket_name - ".sockaddr_un($socket_name)."). $?");
my $line;
while (read (SOCK, $line, 1024))
{
print "Client: ${line}\n";
}
close SOCK;
}
## server activity
sub process_request
{
my $help = `ls`;
print $help;
}
1;