Re: Daemonising to continue asynchronously
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Daemonising to continue asynchronously

From: Andy Jeffries <news@andyjeffries.co.uk>
Date: Tue Apr 25 2006 - 00:24:51 CEST

On Mon, 24 Apr 2006 14:45:34 -0700, fletch wrote:
>> For anyone interested, a working function to become a Daemon (background
>> task, unattached from the parent process) from a PHP CLI script is:
>
> <sinp code>
>
> this is useful code but I would like to point out that a daemon should
> automatically restart when it dies unexpectedly, and ensure that only one
> instance is running, not covering these cases is usally a bad thing. It
> depends what the daemon does of course.

Absolutely, daemon probably isn't the right word, fully detached process
would probably be better.

Although Apache is a daemon, but if the main apache process dies then it
won't automatically restart by itself will it (it relies on
start-stop-daemon or the like).

Anyway, thought the code may help someone in the future.

Cheers,

Andy

-- 
Andy Jeffries MBCS CITP ZCE   | gPHPEdit Lead Developer
http://www.gphpedit.org       | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos
Received on Mon May 1 03:03:27 2006