Jochem:
won't it? what does it do? does it go into and endless loop and bring your 
machine to a halt
by any chance? .. because by looking at it, as long as $in['bg'] is not set and 
not equal to
true it's going to keep spawning sub-shells with cmdlines that call itself.

Me:
You haven't read my message? It works fine when Im running it from the shell

When I do:

`/usr/local/bin/php /www/admin.gammacash.com/test/test_fork.php bg=1 2>&1 
/var/log/test.log &`
you can see bg=1

its the passing arguments!
any other suggestions?



Jochem Maas wrote:
Frederic Belleudy wrote:
don't fork webserver processes, granted it doesn't fix the problem,
but you really
should be doing it anyway.

I'm guessing that the pcntl extension is not compiled into the
webserver php SAPI,
it's a really big guess because you didn't supply the code you use to
do the forking with.

Ok then you want to have the fork code!

'want' is putting it strongly - unless of course your handing out AudiRS4's
in which case 'want' is spot on.

I'm doing a complete example
====================

My script is forking on itself.
So from my browser I go on:
http://localhost/test_fork.php

My code in test_fork.php is :

<?
$in = get_shell_args($_SERVER['argv']); // DONT PAY ATTENTION TO THAT

does $_SERVER['argv'] exist at all? does your error reporting include E_NOTICE?
what is the value of the ini setting 'register_argc_argv'?

FUNCTION, it a made home function

if($in['bg']) {
   print "HERE";     sleep(30);
}
else {
   print "forking";
   `/usr/local/bin/php /www/admin.gammacash.com/test/test_fork.php bg=1
2>&1 /var/log/test.log &`
}
?>

So Im assuming that the fork will get the bg argument, in this case I
should receive "HERE" in /var/log/test.log (did tail -f
/var/log/test.log while I was running the script)
I've put a sleep 30 seconds to get the fork PID number.

no idea how the sleep() will help.

Unfortunately, when I do execute test_fork.php from the web, it wont
execute itself in background.

won't it? what does it do? does it go into and endless loop and bring your 
machine to a halt
by any chance? .. because by looking at it, as long as $in['bg'] is not set and 
not equal to
true it's going to keep spawning sub-shells with cmdlines that call itself.

This method was running fine with my old config.

The script works perfectly because if Im executing test_fork.php from
the shell, the fork is working fine!

and what is the value of the ini setting 'register_argc_argv' when running
via the php CLI SAPI?



--
Frederic Belleudy
Programmer
PWIdeas
ICQ #: 253-372-030
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to