Under apache, you inherit all of the apache sockets when the libc forks
and execs your script.

This causes some problems (there are one or two bug reports about this
in the bug db) with processes waiting around on the sockets.

It looks like there was some code in the apache SAPI to avoid this
problem, but it is currently commented out with an explanation that it
is "problematic".

I've asked about this problem a few times, but no one seems to notice my
questions or have time to reply.

So, we know of the problem, we know roughly how to fix it, but no one
can explain why we can't fix it :)

--Wez.

On Thu, 29 May 2003, Brian Moon wrote:

> I am trying to figure out what is internally different about exec between
> CLI and mod_php.
>
> If exec() a script from CLI and said script forks, I get my prompt right
> back.
>
> test.php
> ------------
> <?php
>
> exec("/home/brianm/fork.php");
>
> ?>
>
>
> fork.php
> ------------
> #!/usr/local/bin/php
> <?php
>
> $pid = pcntl_fork();
>
> if ($pid == -1) {
>     trigger_error("Could not fork __FILE__", E_USER_ERROR);
>     exit();
> } elseif($pid>0) {
>     exit();
> }
>
> touch("/tmp/file.txt");
> sleep(5);
>
> ?>
>
> However, if I run test.php from mod_php in Apache, the parent zombies and
> exec() waits for the forked process to finish.
>
> What is the difference here and is there any hope of having exec in mod_php
> work the same as it does in CLI?
>
> Brian Moon
> dealnews.com
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to