in reply to Re: Re: Closing parent CGI after fork()
in thread Closing parent CGI after fork()
You probably want to close STDIN and STDERR too
You probably don't want to do any of this stuff, but you'll find you have to... :(
Even though the valuable information found by following links to merlyn's nodes/articles elsewhere in this thread only talk about closing STDOUT, I found I had to close STDIN and STDERR, as well. This is for Apache 2. I had to jump through some hoops to redirect the child's STDERR to a file and later send anything found there to the apache error_log, rather than lose any STDERR output produced by the child... a bit ugly, but it works.
Also, I found I had to reopen all 3 filehandles (to/from /dev/null for STDOUT and STDIN, to a file for STDERR) as well, since my child is opening other files, and if you just close STD(IN|OUT|ERR), the next time you open a file it will get file descriptor 0, 1, or 2, which is essentially reopening STD(IN|OUT|ERR), and I found this causes apache to hang again! Ugh. forker beware!
HTH
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Closing parent CGI after fork()
by hambo (Novice) on May 11, 2004 at 00:31 UTC | |
by edan (Curate) on May 31, 2004 at 14:04 UTC |