in reply to Daemonization of IO::Socket Script
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Daemonization of IO::Socket Script
by landonc (Novice) on Aug 08, 2003 at 18:31 UTC | |
|
Re: Re: Daemonization of IO::Socket Script
by landonc (Novice) on Aug 08, 2003 at 18:33 UTC | |
|
Re: Re: Daemonization of IO::Socket Script
by landonc (Novice) on Aug 08, 2003 at 18:46 UTC | |
by skyknight (Hermit) on Aug 08, 2003 at 19:42 UTC | |
by landonc (Novice) on Aug 08, 2003 at 20:27 UTC |