clean up forking code in example

This commit is contained in:
Anthony Minessale 2012-05-14 07:13:26 -05:00
parent 172e4a3041
commit e7b4821844
1 changed files with 13 additions and 3 deletions

View File

@ -61,11 +61,17 @@ my $xml = qq#
</document>
#;
$SIG{CHLD} = "IGNORE";
while (my $request = $scgi->accept) {
# fork every new req into its own process (optional)
next unless(my $pid = fork());
my $pid = fork();
if ($pid) {
$request->close();
next;
}
my $handle = $request->connection;
$request->read_env;
@ -89,5 +95,9 @@ while (my $request = $scgi->accept) {
#print $handle "Content-Type: text/xml\n\n";
print $handle $xml;
exit if (!$pid);
exit unless $pid;
}