in reply to Re: How to run POE as a daemon
in thread How to run POE as a daemon
yet you would have me believe it is.while (1) { print "Enter a number: "; $Number = <STDIN>; chomp($Number); print "You entered - $Number.\n"; }
When I said daemon, I meant having true daemon characteristics, not kinda sorta daemon-like. Fork and exit, setsid, chdir /, close or redirect STDIN, STDOUT, STDERR. Here's the example from Matt Sergeants' talk:
This example fails in the same way: POE::Kernel's run() method was never called.use POE; use POSIX; $|++; sub become_daemon { my $child = fork; die "Can't fork: $!" unless defined($child); exit(0) if $child; # parent dies; POSIX::setsid(); # become session leader open(STDIN,"</dev/null"); open(STDOUT,">/dev/null"); open(STDERR, '>&STDOUT'); umask(0); # forget file mode creation mask $ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; } become_daemon(); # MUST do this before we create any sessions POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("loop") }, loop => sub { $_[KERNEL]->delay_set("loop", 10) }, }); $poe_kernel->run(); exit(0);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: How to run POE as a daemon
by Matts (Deacon) on Oct 02, 2002 at 13:16 UTC | |
|
Re: Re: Re: How to run POE as a daemon
by hossman (Prior) on Oct 02, 2002 at 00:39 UTC | |
|
Re: Re: Re: How to run POE as a daemon
by Anonymous Monk on Oct 01, 2002 at 22:19 UTC | |
by Matts (Deacon) on Oct 02, 2002 at 13:24 UTC |