Hi,

I have a problem with the module Thread::Pool-0.32.
I need to set my script as a daemon, but when i use this module the program
kill the threads.

The output of my script is:

        starting a new work with
        starting a new work with
        starting a new work with
        starting a new work with
        starting a new work with
        starting a new work with
        starting a new work with
        starting a new work with
        starting a new work with
        starting a new work with
        starting a new work with
        starting a new work with
        starting a new work with
        starting a new work with
        Perl exited with active threads:
                20 running and unjoined
                0 finished and unjoined
                0 running and detached

And the source code is:
= = = = = = = = * * * * * * * * * * = = = = = = = =
my $pool = Thread::Pool->new(
                {
                       optimize => 'memory',
                       do => \&check_system,
                       pre => sub {shift; print "starting a new work with
@_\n" },
                       post => sub { print "stopping the work\n" },
                       frequency => 10,
                       autoshutdown => 1,
                       workers => 20,
                       maxjobs => 100,
                       minjobs => 10,
                }
        );

sub daemon
{
        chdir "/";
        open STDIN, '/dev/null';
        fork && exit;
        setsid();
        if (open PID, '>', '/var/run/faxqr.pid')
        {
                print PID "$$\n";
                close PID;
        }
}

daemon();
scan_files();
= = = = = = = = * * * * * * * * * * = = = = = = = =

First i initialice the pool and then i set the process as a daemon. Then i
call the scan_files() function.

I also test to initialice the pool inside the daemon() function and between
daemon() and scan_files(). Doing that, the output is blank, but it doesn't
work.

Thank you for your help.

-- 
A greeting,

Javier.

Reply via email to