[PHP] pcntl_fork behavior with php version 5.1.2
Hi, i got some trouble with a PHP script using pcntl_fork do run some work in background. Runnig my script on my development system (PHP version 5.3.3-7) it behaves like intended. But running it on my production test system (PHP version PHP 5.1.2), i got some strange results. The problem is, that when i logout from my SSH session the console closes not properly, like somethings is kept open. Sadly, updating this old PHP version is not a option... :/ Does anyone have an idea whats going on? Thanks in advance Ralf The script is this: #!/usr/bin/env php ?php $pid = pcntl_fork(); if ($pid == -1) { die('Fork failed!'); } else if($pid 0) { exit(0); // close parent process } else { // child process: while(true) { sleep(10); // do your work -- stripped } } ? do not work with: PHP 5.1.2 with Suhosin-Patch 0.9.6 (cli) (built: Dec 12 2007 02:42:35) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies works with: PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 08:24:40) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
Re: [PHP] pcntl_fork behavior with php version 5.1.2
On 03/29/2012 12:49 PM, Ralf Gnädinger wrote: Hi, i got some trouble with a PHP script using pcntl_fork do run some work in background. Runnig my script on my development system (PHP version 5.3.3-7) it behaves like intended. But running it on my production test system (PHP version PHP 5.1.2), i got some strange results. The problem is, that when i logout from my SSH session the console closes not properly, like somethings is kept open. Sadly, updating this old PHP version is not a option... :/ Does anyone have an idea whats going on? Thanks in advance Ralf The script is this: #!/usr/bin/env php ?php $pid = pcntl_fork(); if ($pid == -1) { die('Fork failed!'); } else if($pid 0) { exit(0); // close parent process } else { // child process: while(true) { sleep(10); // do your work -- stripped } } ? do not work with: PHP 5.1.2 with Suhosin-Patch 0.9.6 (cli) (built: Dec 12 2007 02:42:35) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies works with: PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 08:24:40) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH This sounds more like an OS issue then a PHP issue. What are the two OSs involved? -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pcntl_fork behavior with php version 5.1.2
On 29 Mar 2012, at 20:49, Ralf Gnädinger wrote: i got some trouble with a PHP script using pcntl_fork do run some work in background. Runnig my script on my development system (PHP version 5.3.3-7) it behaves like intended. But running it on my production test system (PHP version PHP 5.1.2), i got some strange results. The problem is, that when i logout from my SSH session the console closes not properly, like somethings is kept open. Sadly, updating this old PHP version is not a option... :/ Does anyone have an idea whats going on? Thanks in advance Ralf The script is this: #!/usr/bin/env php ?php $pid = pcntl_fork(); if ($pid == -1) { die('Fork failed!'); } else if($pid 0) { exit(0); // close parent process } else { // child process: while(true) { sleep(10); // do your work -- stripped } } ? do not work with: PHP 5.1.2 with Suhosin-Patch 0.9.6 (cli) (built: Dec 12 2007 02:42:35) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies works with: PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 08:24:40) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH You need to detach the child from the terminal using posix_setsid(). I don't know why it's working on your development machine, but it's probably simply that you're not seeing this issue due to how you access that development machine. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pcntl_fork behavior with php version 5.1.2
development os is Debian GNU/Linux 6.0 test os is SUSE LINUX 10.1 (i586) Am 29. März 2012 23:02 schrieb Jim Lucas li...@cmsws.com: On 03/29/2012 12:49 PM, Ralf Gnädinger wrote: Hi, i got some trouble with a PHP script using pcntl_fork do run some work in background. Runnig my script on my development system (PHP version 5.3.3-7) it behaves like intended. But running it on my production test system (PHP version PHP 5.1.2), i got some strange results. The problem is, that when i logout from my SSH session the console closes not properly, like somethings is kept open. Sadly, updating this old PHP version is not a option... :/ Does anyone have an idea whats going on? Thanks in advance Ralf The script is this: #!/usr/bin/env php ?php $pid = pcntl_fork(); if ($pid == -1) { die('Fork failed!'); } else if($pid 0) { exit(0); // close parent process } else { // child process: while(true) { sleep(10); // do your work -- stripped } } ? do not work with: PHP 5.1.2 with Suhosin-Patch 0.9.6 (cli) (built: Dec 12 2007 02:42:35) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies works with: PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 08:24:40) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH This sounds more like an OS issue then a PHP issue. What are the two OSs involved? -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/
Re: [PHP] pcntl_fork behavior with php version 5.1.2
I will try posix_setsid(). Both machines were accessed via a ssh client (e.g. putty or ssh from a other linux box). Thanks for your advice. Am 29. März 2012 23:08 schrieb Stuart Dallas stu...@3ft9.com: On 29 Mar 2012, at 20:49, Ralf Gnädinger wrote: i got some trouble with a PHP script using pcntl_fork do run some work in background. Runnig my script on my development system (PHP version 5.3.3-7) it behaves like intended. But running it on my production test system (PHP version PHP 5.1.2), i got some strange results. The problem is, that when i logout from my SSH session the console closes not properly, like somethings is kept open. Sadly, updating this old PHP version is not a option... :/ Does anyone have an idea whats going on? Thanks in advance Ralf The script is this: #!/usr/bin/env php ?php $pid = pcntl_fork(); if ($pid == -1) { die('Fork failed!'); } else if($pid 0) { exit(0); // close parent process } else { // child process: while(true) { sleep(10); // do your work -- stripped } } ? do not work with: PHP 5.1.2 with Suhosin-Patch 0.9.6 (cli) (built: Dec 12 2007 02:42:35) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies works with: PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 08:24:40) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH You need to detach the child from the terminal using posix_setsid(). I don't know why it's working on your development machine, but it's probably simply that you're not seeing this issue due to how you access that development machine. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/