(Disclaimer - I'm typing this reply from a terminal window using lynx so my formatting and layout may appear absolutely horrible)

The problem here that I can see, from the code snippet provided is the path being passed to the open statement. The normal behaviour of Proc::Daemon as part of the initialisation process is to chdir to the root directory - This will greatly impact upon your script if relative paths are being used. The most likely thing that is happening here is that your script, finding itself in the root directory, cannot open the file FDserv.p and is ceasing execution. The reason why this is not returning an error to your screen from the die statement is because all open filehandles, including STDOUT, STDIN and STDERR, are closed by Proc::Daemon - Note that other things such as user permissions may also play a role at this point.

This brings me to another point - As the standard filehandles are closed as part of the initialisation process of Proc::Daemon, it is necessary to incorporate another means of error reporting, such as the system log or a dedicated application log file, as opposed to reporting errors to STDERR - This step alone should help you determine the cause of the error at hand.

Update - If the main role at hand is to manipulate a PID file, then the module Proc::PID::File may also be of interest.


In reply to Re: Daemonize and open a file by rob_au
in thread Daemonize and open a file by JamieD

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.