Here's what I use for daemonizing...

use POSIX qw(setsid); sub daemonize { die "Can't fork" unless defined (my $child = fork()); exit 0 if $child; setsid(); open(STDIN, "</dev/null"); open(STDOUT, ">/dev/null"); open(STDERR, ">&STDOUT"); chdir '/'; umask(0); $ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin'; return $$; }

It looks mostly like what you have... What about putting some logging statements in places to figure out where exactly the script is going haywire? Maybe your socket is getting fouled up, so accept returns undef right away, and $time_to_die is false, and so you're in an insanely tight loop that isn't doing any IO, but rather just spinning on the CPU. How about that as an idea? Try putting a print statement right after your "until", and another one right after your "while" to figure out what kind a control path you're experiencing.


In reply to Re: Daemonization of IO::Socket Script by skyknight
in thread Daemonization of IO::Socket Script by landonc

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.