#18707 [NEW]: Can't run PHP script in background from a PHP CGI script?
| From: | scottg at particle dot net | Date: | Fri, 02 Aug 2002 14:18:13 +0000 |
| Subject: | #18707 [NEW]: Can't run PHP script in background from a PHP CGI script? | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-15826@lists.php.net to get a copy of this message | ||
From: scottg@particle.net
Operating system: Linux 2.2.20
PHP version: 4.2.1
PHP Bug Type: Unknown/Other Function
Bug description: Can't run PHP script in background from a PHP CGI script?
This is the strangest thing in the world and I have no idea why it happens.
I'm using Linux 2.2.20 with PHP 4.2.1. I have PHP compiled in as a
module and I have an external PHP binary for CGI work.
I want bg.cgi to run in the background.
start.cgi:
#!/usr/php/bin/php -q
<?
system("/usr/php/bin/php -f /somepath/bg.cgi >>/dev/null 2>>/dev/null
&");
echo "Ok!\n";
?>
bg.cgi:
#!/apps/php/bin/php -q
<?
sleep(5);
mail ("scottg@nospam.com", "Test Subject", "Test Message");
?>
I run start.cgi with the brower like a normal cgi script -
http://www.whatever.com/start.cgi. The web page says
Ok! like it should.
In the background now I have a bg.cgi process but its going crazy. It
dies and restarts repeatedly. It gots on for about 1 minute then gives
up. The process number increases with each new bg.cgi process. Only one
bg.cgi process every exists though. Strangest thing ever. I never do get
the email message bg.cgi is suspose to send.
If I run start.cgi from the command prompt all is well, only one bg.cgi
runs fine and I get the email after 5 seconds.
Anyone know why bg.cgi runs crazy if called like this?
Oh ya, if I had a start.php:
<html>
<? system("/apps/php/bin/php -q -f /home/scottg/web/run/bg.cgi >>/dev/null
2>>/dev/null &"); ?>
</html>
and just viewied it in the browser so that the php module runs bg.cgi all
works fine too.
--
Edit bug report at http://bugs.php.net/?id=18707&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18707&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18707&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18707&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18707&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18707&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18707&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18707&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18707&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18707&r=globals