You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rasmus Lerdorf <ra...@lerdorf.on.ca> on 1998/02/08 04:07:48 UTC

Re: [PHP-DEV] Re: The Bad News (fwd)

I passed Brian's recent message onto the php-dev list which has a couple
of Windows-weenies on it.  Here is one of the responses.  Contact Steve
directly for more info.

---------- Forwarded message ----------
Date: Sat, 7 Feb 1998 22:23:10 -0500 (EST)
From: Steve Willer <wi...@interlog.com>
To: Rasmus Lerdorf <ra...@lerdorf.on.ca>
Cc: php-dev@php.iquest.net
Subject: Re: [PHP-DEV] Re: The Bad News (fwd)


On Sat, 7 Feb 1998, Rasmus Lerdorf wrote:

> Shane, or perhaps we have some other Windows-heads here, the ApacheNT
> project has hit a bit of a roadblock.  If anybody can shed some light on
> it, please let us know.

I took a closer look at the code, and I would guess that they're
absolutely right and the rtl is at fault. It's not surprising to me --
full support for Unix-like process stuff hasn't ever been Microsoft's
forte (I've written a cross-platform system monitoring tool that works by
launching processes, so I have some experience with this). Fortunately,
the fix isn't too difficult, and is in many ways simpler than the Unix
equivalent.

On Unix, you would fork(), then dup2() stdin, stdout and stderr, then
exec() the child. On Win32, you would use CreatePipe for each of the 
standard fd's (being sure to set
the security attributes' bInheritHandle to TRUE), then stick one end of
the three pipes into hStdInput, hStdOutput and hStdError of the
STARTUP_INFO argument to CreateProcess (being sure to set the
STARTF_USESTDHANDLES flag). Then, any time you want to read or write, use
the low-level ReadFile and WriteFile functions.

A few days ago, I posted some code that spawns a child using the
CreateProcess. For further info, check out the MSVC rtl source: _filbuf.c,
pipe.c, perhaps popen.c.