Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Perl-Sensitive Sunglasses
 
PerlMonks  

Errors from forked process

by rsiedl (Friar)
on Apr 20, 2006 at 00:45 UTC ( [id://544516]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

rsiedl has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

I'm running a CGI script which forks into the background and continues processing while the main script returns a message to the browser.
I would like to know how I can see any errors which might occur in the forked part.
Normally the CGI gets printed to the apache error log but I'm not seeing anything in there comming from the fork (and I know it is having errors).
Can anyone help me out?

Cheers,
Reagen

Replies are listed 'Best First'.
Re: Errors from forked process
by jesuashok (Curate) on Apr 20, 2006 at 01:28 UTC
    Hi

    Points to ponder on Fork and Apache.
    Apache logging pipe, the new child also inherits this connection, including any unprocessed data, and can pick up where the exited child left off.

    Apache runs cleanup code per-child after a fork and before executing cgi scripts. This was not handled properly, and R/Apache caused the child to segfault.

    "Keep pouring your ideas"
Re: Errors from forked process
by aufflick (Deacon) on Apr 20, 2006 at 02:11 UTC
    Like jeshuaok I suspect that Apache post-cgi cleanup is closing your stdout/stderr file handles.

    While not the best final solution, the first thing I would try would be to open a logging file and alias it to STDERR. Something like this:

    open NEW_STDERR, ">/tmp/mylog.$$" or die "with some reasonable message +"; *STDERR = *NEW_STDERR;
Re: Errors from forked process
by blazar (Canon) on Apr 20, 2006 at 05:22 UTC
    I would like to know how I can see any errors which might occur in the forked part.

    Then just have it maintain its own log(s). Either roll a system yourself or use a module like Log::Log4perl.

Re: Errors from forked process
by Anonymous Monk on Apr 20, 2006 at 06:36 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://544516]
Approved by chargrill
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.