in reply to Daemon, log4perl & stderr/stdout
If so, then the parent has to process the child's output and pass it to the logging object. Here's a simple way to do this for just STDOUT:
If it's okay to merge STDOUT and STDERR, you can do something like this:my $pid = open(CHILD, "-|", 'child', @child_args) if ($pid) { while (<CHILD>) { $logger->($_) } } close(CHILD);
if (my $pid = open(CHILD, "-|")) { while (<CHILD>) { $logger->($_); } close(CHILD); } else { open(STDERR, '>&STDOUT'); exec('child', @child_args) || die "exec failed"; }
When Proc::Daemon runs, it somehow takes over STDOUT and STDERR so I don't see the messages.All Proc::Daemon is doing is redirecting STDOUT and STDERR to /dev/null.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Daemon, log4perl & stderr/stdout
by saberworks (Curate) on May 27, 2008 at 22:25 UTC | |
by ikegami (Patriarch) on May 27, 2008 at 22:46 UTC | |
by pc88mxer (Vicar) on May 27, 2008 at 23:17 UTC | |
by ikegami (Patriarch) on May 27, 2008 at 22:59 UTC | |
by saberworks (Curate) on May 28, 2008 at 17:59 UTC | |
by pc88mxer (Vicar) on May 27, 2008 at 22:37 UTC | |
by saberworks (Curate) on May 28, 2008 at 18:00 UTC |