Skip Menu |

This queue is for tickets about the POE CPAN distribution.

Report information
The Basics
Id: 16691
Status: resolved
Priority: 0/
Queue: POE

People
Owner: Nobody in particular
Requestors: chris [...] fedde.littleton.co.us
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



To: bug-POE [...] rt.cpan.org
From: Chris Fedde <chris [...] fedde.littleton.co.us>
Subject: Proc::Daemon::Init() + POE::Wheel::Run == Unexpected Behavior
Date: Thu, 22 Dec 2005 16:21:40 -0700
using POE::Wheel::Run after calling Proc::Daemon::Init() fails. using a simple daemonize routine succeeds. example code is below: -- Chris Fedde -- #!/usr/bin/perl package A::B::C; use strict; use warnings; use POE 'Wheel::Run'; use Proc::Daemon; use Time::HiRes qw(sleep time); use POSIX 'setsid'; my $log; open $log, '>>/tmp/abc.log'; sub daemonize { open STDIN, "/dev/null" or die "Can't read /dev/null: $!"; open STDOUT, ">/dev/null" or die "Can't write to /dev/null: $!"; defined(my $pid = fork()) or die "Can't fork: $!"; exit if $pid; chdir '/' or die "Can't chdir /: $!"; setsid() or die "Can't start a new session: $!"; open STDERR, ">&STDOUT" or die "Can't dup stdout: $!"; } sub output { print $log join( ':', time(), 'got', grep( {defined} @_[ STATE, ARG0, ARG1, ARG2, ARG3, ARG4 ] ) ), "\n"; } sub stdin { goto &output } sub stderr { goto &output } sub error { goto &output } sub stdout { output(@_); $_[KERNEL]->delay_set('put_stuff', 0.5); } sub put_stuff { output(@_); $_[HEAP]->{wheel}->put(scalar localtime); } sub end_it { delete $_[HEAP]->{wheel}; } sub _start { my $wheel = POE::Wheel::Run->new( Program => [qw(/bin/cat -)], StdoutEvent => 'stdout', StdinEvent => 'stdin', StderrEvent => 'stderr', ErrorEvent => 'error', ); print $log '_start'; $_[HEAP]->{wheel} = $wheel; $_[KERNEL]->yield('put_stuff'); $_[KERNEL]->delay_set('end_it', 5); } ################################# # # silly arg proccessor # proc for Proc::Daemon::Init # daemonize for the above daemonize subroutine # no arg to leave in forground. if (@ARGV) { if ($ARGV[0] eq 'proc') { print $log "Proc::Daemon::Init()\n"; Proc::Daemon::Init(); } elsif ($ARGV[0] eq 'daemonize') { print $log "daemonize\n"; daemonize(); } } close $log; open $log, '>>/tmp/abc.log'; POE::Session->create( package_states => [ 'A::B::C' => [qw( _start put_stuff stdin stdout stderr error end_it )] ], ); POE::Kernel->run();
Fixed as of revision 1916. Thanks for the test case; it was vital in finding the problem.