[PHP] forking off in php
hello, I have what may seem like a small problem but its not obvious to me. I have a script that I forked and that part works fine, it forks, tells me the pid like I wanted, and keeps running. Well, the problem that was not apparent to me until about 3 days ago when I was wondering why the script(my php chat server) was crashing at seeminly random times. I finally figured out that when I logged out of my shell in linux, the talker would go down as well. Obviously I don't want that but what do I need to add to the line when i start the script thanks matt ps If it helps, I am running php 4.3.10 on slackware -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] forking off in php
[snip] hello, I have what may seem like a small problem but its not obvious to me. I have a script that I forked and that part works fine, it forks, tells me the pid like I wanted, and keeps running. Well, the problem that was not apparent to me until about 3 days ago when I was wondering why the script(my php chat server) was crashing at seeminly random times. I finally figured out that when I logged out of my shell in linux, the talker would go down as well. Obviously I don't want that but what do I need to add to the line when i start the script thanks matt ps If it helps, I am running php 4.3.10 on slackware [/snip] It would have been nice to see your command line. Add '' i.e. /usr/local/bin/foo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forking off in php
On 21 Nov 2005, at 17:39, matt VanDeWalle wrote: I have what may seem like a small problem but its not obvious to me. I have a script that I forked and that part works fine, it forks, tells me the pid like I wanted, and keeps running. Well, the problem that was not apparent to me until about 3 days ago when I was wondering why the script(my php chat server) was crashing at seeminly random times. I finally figured out that when I logged out of my shell in linux, the talker would go down as well. Obviously I don't want that but what do I need to add to the line when i start the script Example1 on the php docs page is what you need: http://www.php.net/manual/en/ref.pcntl.php The important thing is the call to posix_setsid(), which detaches your forked process from your terminal process. Works great for me - I've had PHP daemons running for over 9 months without a break. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forking off in php
On 21 Nov 2005, at 17:47, Jay Blanchard wrote: It would have been nice to see your command line. Add '' i.e. You don't need to do that - the forking script will start, spawn a child process then exit, so adding will do nothing. Having said that, you could achieve something similar by not forking and using nohup (look it up with man) with , however, that will mean it runs as you, whereas a forked process can easily switch users and drop privileges for increased security. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forking off in php
ah ok thanks, am reading it now On Mon, 21 Nov 2005, Marcus Bointon wrote: On 21 Nov 2005, at 17:39, matt VanDeWalle wrote: I have what may seem like a small problem but its not obvious to me. I have a script that I forked and that part works fine, it forks, tells me the pid like I wanted, and keeps running. Well, the problem that was not apparent to me until about 3 days ago when I was wondering why the script(my php chat server) was crashing at seeminly random times. I finally figured out that when I logged out of my shell in linux, the talker would go down as well. Obviously I don't want that but what do I need to add to the line when i start the script Example1 on the php docs page is what you need: http://www.php.net/manual/en/ref.pcntl.php The important thing is the call to posix_setsid(), which detaches your forked process from your terminal process. Works great for me - I've had PHP daemons running for over 9 months without a break. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php