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: Mon Apr 24 2006 - 21:00:55 CEST

On Mon, 24 Apr 2006 09:45:18 -0700, fletch wrote:
> Yup, children are killed when the server process dies. (try telling that
> to non programming folk.) I don't think that you can do this from a
> request. I would either set it up properly as a daemon if I have access to
> the boot proceedure, or get cron to start it, making sure the script dies
> if there is already one instance running.
>
> I could be wrong about this, but I have looked into it before.

Found the problem, see my reply to my post. The become_daemon function
was working fine, but it still held the file handle to stdout open (as
child processes inherit open file handles) and therefore PHP waited for an
EOF on the stdout handle from the child.

Closing stdout (along with the previously described pcntl_fork,
posix_setsid, pcntl_form) works a charm.

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:18 2006