I’m trying to use fork for the first time, so I can redirect the user’s web browser and then keep processing. I looked up the code for using fork, but my child process doesn’t execute (i.e., the file doesn’t get created). What am I doing wrong?
#! /usr/bin/perl
if ($pid = fork) { }
else {
close STDOUT();
open(FILE,'>test.txt');
print FILE time;
close(FILE);
exit(0);
}
print "Location: http://mydomain.com/\n\n";
STDOUT()makes Perl look for a function calledSTDOUT, and not finding one, aborts your child process.You just need to say
or
Even if you can only test this program in a web browser, the error message should still show up in the server error log.