[EMAIL PROTECTED] wrote:
Unfortunately no.
On win32 for instance, fork() doesn't exist at all.

Sure it does, it's just a different model.

<snip href="http://msdn.microsoft.com/";>
One of the largest areas of difference is in the process model. UNIX has fork; Win32 does not. Depending on the use of fork and the code base, Win32 has two APIs that can be used: CreateProcess and CreateThread. A UNIX application that forks multiple copies of itself can be reworked in Win32 to have either multiple processes or a single process with multiple threads. If multiple processes are used, there are multiple methods of IPC that can be used to communicate between the processes (and perhaps to update the code and data of the new process to be like the parent, if the functionality that fork provides is needed). For more on IPC, see Interprocess Commuications.
</snip>


fork() doesn't work exactly as planned, i.e.:

        pid2 = fork();
        if(pid2 == 0) {
                /* hi, i'm the child */

That won't exactly work because Windows requires an exact image to load from, and it will treat it as if you had just started it (EIP = ENTRY POINT). However, some uses of fork() revolve around something like this:

        pid2 = fork();
        if(pid2 == 0) {         
                execve("/bin/part2", ...)

In this case, great news! It'll work. Use CreateProcess().

The assumption that Win32 doesn't have fork() isn't *entirely* correct. It doesn't have POSIX fork(), but it can do some uses of fork(). CreateThread() is something else to look into, but if you use fork() for threading, you're taking the long road.

If I am following you right, wouldn't a fork() followed by an exec
(one of the many forms) do what you're needing?

If it will, CreateProcess() will work, like I said. Look into http://pecl.php.net/package/ffi as well. You can't pass writable structures (0.4, WEZ!? :P) but you're bound to be able to whip something together if you're willing to play dirty.


Otherwise, just use exec(). :D


-- _ (_)___ Jed Smith, Code Ninja | / __| RFBs: [email for info] | \__ \ +1 (541) 606-4145 _/ |___/ [EMAIL PROTECTED] (Signed mail preferred: PGP 0x703F9124) |__/ http://personal.jed.bz/keys/jedsmith.asc

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



Reply via email to