I wrote a simple test daemon using Proc::Daemon . Here is the daemon:
#!/usr/bin/perl
use Proc::Daemon;
$daemon = Proc::Daemon->new(
work_dir => '/scripts/',
child_STDOUT => '/scripts/child.log',
child_STDERR => '+>>debugchild.txt',
pid_file => 'pid.txt',
exec_command => 'perl /scripts/test.pl'
);
foreach(@ARGV)
{
if ( /install/i )
{
$Kid_1_PID = $daemon->Init;
}
elsif (/remove/i)
{
$stopped = $daemon->Kill_Daemon();
}
}
And here is test that it executes:
#!/usr/local/bin/perl
while (1) {
print "test\n";
sleep(1);
}
The while loop works fine with just the print statement, but when I add sleep(); the log is empty. Why would this be?