2009/8/18 Per Jessen <p...@computer.org>:
> Jim Lucas wrote:
>> Does anybody know how to use PHP as a daemon without the use of
>> pcntl_fork.
> Sure. Just start it and leave it running.
>> I want to launch a daemon out of the /etc/rc.local when the system
>> starts.
> Yep, I do that all the time.
>> Anybody have any idea on how to do this?
> On an openSUSE system I would just use 'startproc', but elsewhere you
> could use setsid or nohup.  I.e. create your CLI script with a
> hash-bang, then start it
> nohup <script> 2>&1 1>/dev/null &
> /Per

Again, that's not a daemon. If it is sufficient to run a background
process then that's fine, but that doesn't make it a daemon (although
it shares some things in common with a daemon). The background process
still has a controlling terminal (even if input and output have been
redirected), and a fully-implemented daemon will typically perform
other tasks which make it a good system citizen, such as: becoming
session leader, chroot'ing to / so that the filesystem it was started
from can be unmounted if necessary, and so on.

The difference may or may not be important, depending on the task at
hand. However, if an admin thinks he's got a daemon on his hands he
may wonder why things behave weird if what he really has is just
something which fakes it with & and nohup, since none of the important
daemon housekeeping has been dealt with.


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to