Subject: | Suggested changes to Proc::DaemonLite |
Nicola,
Nice module--combines a bunch of functionality that I keep having to
reimplment. Thanks!
I had a few suggestions that stem from an error I ran into. I have a
script that I want to initialize and report any errors before
daemonizing. During initialization, I need to drop privileges in order
to open a file as nobody (all before I want to call init_server).
Because PIDPATH is defined before I drop privilege and _open_pid_file is
called after, the script blows up at 'print $fh $$;'. (I'm not sure why
it doesn't die in the IO::File->new, but it doesn't)
Anyway, moving PIDPATH into _getpidfilename would solve the problem.
For reference, I have attached a test file that dies during init_server
(nothing is written to the log).
Subject: | test.pl |
#!/usr/bin/perl
use strict;
use warnings;
use Proc::DaemonLite qw(:all);
drop_priv();
my $pid = init_server(undef,'nobody','nogroup');
log_warn "Daemonized with pid = $pid\n";
sub drop_priv {
my ($login,$pass,$uid,$gid) = getpwnam(shift || 'nobody');
($),$() = ("$gid $gid", $gid); die $! if $!;
($<,$>) = ($uid,$uid); die $! if $!;
}