good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Detached forking in a CGI scriptby xylose (Initiate) |
on Apr 29, 2016 at 15:06 UTC ( [id://1161882]=perlquestion: print w/replies, xml ) | Need Help?? |
xylose has asked for the wisdom of the Perl Monks concerning the following question: I'm having a problem satisfying a number of constraints in a CGI script I'm writing. I need the script to fork a child process and to get hold of the pid of this child, but to then not make the parent (the CGI process) wait for the child, and allow it to exit immediately. One extra complication is that in the child I exec a new program (an R script), but capture STDOUT and STDERR into log files, so I can't close those filehandles before doing the exec. I've tried a number of different approaches, but anything which gives me the pid and starts the child process correctly always makes the parent hang until the child is done. My current (not working) best guess is:
In this version the child runs, but the parent doesn't exit until the child has completed. Any ideas how I can have my cake and eat it? Thanks.
Back to
Seekers of Perl Wisdom
|
|