develooper Front page | perl.beginners | Postings from October 2009

Re: Daemon::Easy and self-killing

Thread Previous
Steve Bertrand
October 14, 2009 20:15
Re: Daemon::Easy and self-killing
Message ID:
Michael Pobega wrote:
> I'm using the Daemon::Easy module to write a basic Perl daemon, but I'm
> wondering if there is a way to stop the daemon from within the script (as
> opposed to running "./ stop")? Currently I have a subroutine to do
> this, but it doesn't seem to cleanly erase the pid file.
>> &killMe {
>>         unlink("/tmp/.idle_kick-$");
>>         system("gnome-session-save --force-logout"); # the point of the daemon
>>         exit;
>> }
> And yes, $PID is pointing to the proper file (I've used 'print' to manually get
> the value, and it's all right).
> I've read all of the documentation for the Daemon::Easy module, 

The Daemon::Easy module is in version 0.0.1.

I'm but a humble beginner, but much of the code within the source of
said module resembles code that I've been writing/using/throwing away as
'test building blocks' for ``stages'' of a larger project.

I think that it is unacceptable to release anything to the CPAN that
doesn't have:

- POD (documentation) that doesn't contain a description of usage for
each function/method that is 'publicly' available. Documentation should
describe the subroutine well enough to have a real developer ask
implementation questions, as opposed to thinking 'wtf!?'

... a CPAN release also shouldn't have:

- code that clobbers the symbol table without clear reasoning and
warning in the documentation OR within the code ( especially if wrecking
a non-OO namespace )

As someone who is staging to become a CPAN author (but not there yet),
I'd recommend that you mail the author with your concerns. If the CPAN
author has honoured their responsibility, then there will be a
responsive email address within the perldoc of the project.

fwiw, to answer your question about not cleanly erasing the pid, I would
first manually ensure the code ( it has comments that contain typos,
does the code? ), then I would focus on file-system permissions that the
user who is executing the code has. ( ensure the code before you allow
it to 'unlink' as a privileged user ).

I'd find something else or re-write it, if I were you...


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About