Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl
fork/CGI/Apache problem
 

Index | Next | Previous | View Flat


marco.kleefman at cmg

Nov 2, 2001, 6:30 AM


Views: 2352
Permalink
fork/CGI/Apache problem

Hello everybody,

I am new to the list. I have a question I hope you can help me with. It is
not a modperl question, just a normal perl question related to Apache/CGI.

I have this script which forks off a process which does something. I already
encountered the problem of my browser waiting for the child to be finished.
I solved it by closing STDIN/OUT/ERR. But I still have another problem...
Somehow all print statements in my script which occur before the fork-part
of the script are printed twice! I have tried to unbuffer STDOUT, but no
luck until now...

Here's my script:

#! /usr/bin/perl
print "start: pid=$$\n"; # this line gets printed twice!
print "Content-type: text/html\n\n"; # this line gets printed twice!

if (!defined ($pid = fork))
{
die "Unable to fork: $!\n";
}
elsif (! $pid)
{
warn "child: pid=$$\n";

# this is the branch for the child process
close(STDIN); close(STDOUT); close(STDERR);
sleep(60); # pause for 1 minute
exit; # terminate the child process
}
else
{ # this is the branch for the parent
warn "parent: pid=$$ (child=$pid)\n";
...print some HTML code....
exit; # terminate the parent process
}

Best regards,

Marco
The Netherlands

PS I have searched 30 pages of old messages related to forking, but no luck
there! Still I have the feeling that my problem is something trivial... :(

Subject User Time
fork/CGI/Apache problem marco.kleefman at cmg Nov 2, 2001, 6:30 AM
    Re: fork/CGI/Apache problem rlandrum at capitoladvantage Nov 2, 2001, 7:24 AM
    RE: fork/CGI/Apache problem Charles.Day at frontstep Nov 2, 2001, 7:53 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.