You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Mike P. Mikhailov" <mi...@sibtel.ru> on 2001/10/15 08:59:48 UTC

Apache output in the forked process

Hello modperl,

  I'm run into weird problem: apache output (HTTP headers and entity)
  appears in the my own separate log file.

  Here is scenario:
  I'm fork a new process, cleanup for exec, redirect STD(IN|ERR|OUT)
  in the /dev/null,/tmp/err,/tmp/out correspondingly, chdir '/' and
  start long running job. In the first call to the my logger print
  subroutine it open own log file and writing messages into it. It's
  all work fine, but when size of the log file near 4KB I see a HTTP
  header and chunk with log file content. It looks like a HTTP
  response but why in my log file ? Logger print method echoed message
  in the log file and in the STDOUT also. I'm mentioned before that I
  redirect STDOUT in the /tmp/out. But /tmp/out is zero size. (BTW:
  when warn messages STDERR (/tmp/err) always contain that I'm send
  into it). I stop echo messages in the STDOUT and my log file
  contains what I want. But I'm think this is because I'm not
  STDOUT'ed anythig and apache output buffer do not grow enought to
  send to the client. It's ok but why in my log file ? Any thoughts
  why it is happen or start investigate why from ?

-- 
Best regards,
 Mike                          mailto:mike@sibtel.ru



Re: Apache output in the forked process

Posted by Stas Bekman <st...@stason.org>.
Mike P. Mikhailov wrote:

> Hello modperl,


HELO Mike


>   I'm run into weird problem: apache output (HTTP headers and entity)
>   appears in the my own separate log file.
> 
>   Here is scenario:
>   I'm fork a new process, cleanup for exec, redirect STD(IN|ERR|OUT)
>   in the /dev/null,/tmp/err,/tmp/out correspondingly, chdir '/' and
>   start long running job. In the first call to the my logger print
>   subroutine it open own log file and writing messages into it. It's
>   all work fine, but when size of the log file near 4KB I see a HTTP
>   header and chunk with log file content. It looks like a HTTP
>   response but why in my log file ? Logger print method echoed message
>   in the log file and in the STDOUT also. I'm mentioned before that I
>   redirect STDOUT in the /tmp/out. But /tmp/out is zero size. (BTW:
>   when warn messages STDERR (/tmp/err) always contain that I'm send
>   into it). I stop echo messages in the STDOUT and my log file
>   contains what I want. But I'm think this is because I'm not
>   STDOUT'ed anythig and apache output buffer do not grow enought to
>   send to the client. It's ok but why in my log file ? Any thoughts
>   why it is happen or start investigate why from ?

It seems to me that you've overriden the STDOUT of the parent process 
and that's why you see this behavior. Try not to touch the STD* handles 
at all, is everything going as usual? If so, check that you override 
STD* in the child process.

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/