|
Posted by Chapman Flack on 10/06/05 16:29
I wrote:
> In another language, the right way to do it would be to exec(2)
> - pcntl_exec in PHP speak - the filter, with the open file
> dup'd on its standard input. exec /replaces/ PHP with the
> filter, so if PHP hasn't written the headers by then, it never
> will.
ECRIA Public Mail Buffer wrote:
> A fallacious assertion. Once your command is run, your
> PHP script proceeds with execution. It does not die as
> a result of the call to exec().
You might look again at what I wrote. You'll see I was
describing what would be the obvious, efficient solution in a
language other than PHP, involving the POSIX exec(2), which is
not what PHP calls "exec" but rather what PHP calls "pcntl_exec."
If you are not familiar with the effects of pcntl_exec, you will
be able to find it in section CVI of the PHP manual.
The point of my post was to find out if there is any way in PHP
to implement the same efficient solution, without an extra fork
and without a race condition. It still appears that there isn't,
but if the extra process creation is tolerable, it turns out the
race condition can be avoided by using an undocumented feature of
proc_open, found in the source ext/standard/exec.c and now noted
on the proc_open manual page.
I understand how you might have thought I was off the mark if
you read the posting too quickly and thought I was talking about
what PHP calls "exec." By and large, it never hurts to give
something a closer second reading, if you find yourself about
to call it "fallacious."
Navigation:
[Reply to this message]
|