Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I've written a couple of daemons in Perl that I want to be controlled by the SysV init subsystem in Debian GNU/Linux (2.2.19 kernel). They provide a start-stop-daemon utility that will stop and start other programs; it knows enough to check the running process information against the PID saved in a file in /var/run.

The problem is that when I go to stop my Perl daemon, the start-stop-daemon can't find the process. It looks at the PID and determines that the name of the running process is not the same as the script name (of course, the running process is named "perl").

I've tried assigning to $0 to fake the name, but this doesn't work either (the name does not compare the same). It also seems that assigning to $0 does something funny to the apparent process name; this program:

#!/usr/bin/perl -w my $pid = fork; exit if $pid; $0 = "a"; sleep 60;

causes ps to show the name of the process as "a" followed by over 900 spaces.

I have also tried changing the --name and --exec options to start-stop-daemon to various flavors of perl, /usr/bin/perl, "/usr/bin/perl myscript.pl", all without success.

Has anyone got an idea of how to get this working? The reason I wanted to use start-stop-daemon is that it looks at the process information to determine whether the PID in the file is in fact valid.


In reply to Perl daemons and /etc/init.d scripts by bikeNomad

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (11)
    As of 2014-09-17 13:34 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (80 votes), past polls