You script only printed once for me. Here's a shortened version I use:
....parent stuff above defined($pid = fork) or die "cannot fork: $!\n"; exit if $pid; close (STDOUT); ...child stuff below -----Original Message----- From: Marco Kleefman [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 8:30 AM To: [EMAIL PROTECTED] Subject: 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... :(