in reply to Proc::Daemon and Log::Log4perl

From the Manual Page of Proc::Daemon:

The Proc::Daemon::Init function does the following:

Note point 6. It closes all open file descriptors. Maybe exchanging two lines in your code does the trick:

Proc::Daemon::Init(); Log::Log4perl->init_and_watch( '/tmp/test_log_daemon.conf', 10 );

Don't know it it works (just an idea), maybe Log::Log4perl->init_and_watch() reopens STDERR or such.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: Proc::Daemon and Log::Log4perl
by jasonk (Parson) on Jun 28, 2006 at 13:08 UTC

    This does work for Proc::Daemon. Anything you want to do that involves file descriptors should be setup after the Init, which avoids a lot of problems. For example, what if your process forks several times, and each child then runs Proc::Daemon::Init()? They will all inherit the same filehandle, which can be annoying for some modules (if I recall correctly the biggest problem with Log::Log4perl is likely to be log entries that overlap) and disastrous for others (DBI handles in particular are something you want to make sure that your child processes aren't trying to share).


    We're not surrounded, we're in a target-rich environment!
Re^2: Proc::Daemon and Log::Log4perl
by Excalibor (Pilgrim) on Jun 28, 2006 at 13:19 UTC

    Yes! That worked!

    And it also worked on the project, once I remembered the ->init_and_watch() method is called within an Initialization module which is use()d in every other module... I simply called our init() function after the Proc::Daemon::Init() call and it worked perfectly...

    Thanks a bunch to all, you're fantastic!

    --
    our $Perl6 is Fantastic;