# php_fork();

- Thread: https://externals.io/message/13835
- Original archive: https://news-web.php.net/php.internals/13835
- Started by overight on 2004-11-14T15:45:26+00:00
- Messages: 18
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #13838 — Andrey Hristov — 2004-11-14T15:40:35+00:00

URL: https://externals.io/message/13835#13838 · In reply to: #13835

Try
 `pcntl_fork()` and the ext/pcntl extension  (*nix only
but I heard someting about cygphp which uses Cygwin
and has ext/pcntl for windows).

Andrey

overight wrote:
> Hello
> 
> What about fork() in php ?
> 
> I have tried to understand c language yesterday, and I have write that 
> in /ext/standard/basic_functions.c:
> 
> PHP_FUNCTION(php_fork){
>     fork();
> }
> 
> (and a few lines to decalare this function)
> 
> And it's work !
> Now I can fork my php scripts with the php_fork() function :)
> 
> Is it possible to hope that a same function will come in futures 
> versions of php ?

---

## #13835 — overight — 2004-11-14T15:45:26+00:00

URL: https://externals.io/message/13835#13835

Hello

What about fork() in php ?

I have tried to understand c language yesterday, and I have write that 
in /ext/standard/basic_functions.c:

PHP_FUNCTION(php_fork){
     fork();
}

(and a few lines to decalare this function)

And it's work !
Now I can fork my php scripts with the php_fork() function :)

Is it possible to hope that a same function will come in futures 
versions of php ?

---

## #13842 — Andrey Hristov — 2004-11-14T15:46:38+00:00

URL: https://externals.io/message/13835#13842 · In reply to: #13840

But as you said support for spoon() can be added. :-)

Andrey

Steph wrote:
> It's not easy to support something that doesn't exist...
> 
> ----- Original Message ----- 
> From: <ilya77@gmail.com>
> To: "Derick Rethans" <derick@php.net>
> Cc: "overight" <overight@free.fr>; <internals@lists.php.net>
> Sent: Sunday, November 14, 2004 5:49 PM
> Subject: Re: [PHP-DEV] php_fork();
> 
> 
> 
> > […]
> 
> wrote:
> 
> > […]

---

## #13837 — Derick Rethans — 2004-11-14T15:48:14+00:00

URL: https://externals.io/message/13835#13837 · In reply to: #13835

> Hello
>
> What about fork() in php ?

http://nl.php.net/pcntl_fork

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #13836 — Sean Coates — 2004-11-14T15:48:16+00:00

URL: https://externals.io/message/13835#13836 · In reply to: #13835

http://php.net/pcntl

S

overight wrote:
> Hello
> 
> What about fork() in php ?
> 
> I have tried to understand c language yesterday, and I have write that 
> in /ext/standard/basic_functions.c:
> 
> PHP_FUNCTION(php_fork){
>     fork();
> }
> 
> (and a few lines to decalare this function)
> 
> And it's work !
> Now I can fork my php scripts with the php_fork() function :)
> 
> Is it possible to hope that a same function will come in futures 
> versions of php ?

---

## #13839 — ilya77@gmail.com — 2004-11-14T15:49:44+00:00

URL: https://externals.io/message/13835#13839 · In reply to: #13837

Any chance to see fork() support for Win32 in the near future?



> 
> 
> > […]
> 
> http://nl.php.net/pcntl_fork
> 
> Derick
> 
> --
> Derick Rethans
> http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #13840 — Steph — 2004-11-14T15:53:23+00:00

URL: https://externals.io/message/13835#13840 · In reply to: #13839

It's not easy to support something that doesn't exist...

----- Original Message ----- 
From: <ilya77@gmail.com>
To: "Derick Rethans" <derick@php.net>
Cc: "overight" <overight@free.fr>; <internals@lists.php.net>
Sent: Sunday, November 14, 2004 5:49 PM
Subject: Re: [PHP-DEV] php_fork();


> Any chance to see fork() support for Win32 in the near future?
>
>
> On Sun, 14 Nov 2004 16:48:14 +0100 (CET), Derick Rethans <derick@php.net>
wrote:
> > […]

---

## #13841 — Derick Rethans — 2004-11-14T15:53:53+00:00

URL: https://externals.io/message/13835#13841 · In reply to: #13839

> Any chance to see fork() support for Win32 in the near future?

No, win32 has no such concept.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #13843 — ilya77@gmail.com — 2004-11-14T15:55:49+00:00

URL: https://externals.io/message/13835#13843 · In reply to: #13841

Can't it be emulated?



> 
> 
> > […]
> 
> No, win32 has no such concept.
> 
> 
> 
> Derick
> 
> --
> Derick Rethans
> http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #13844 — Derick Rethans — 2004-11-14T15:58:39+00:00

URL: https://externals.io/message/13835#13844 · In reply to: #13843

> Can't it be emulated?

The *concept* doesn't exist on Windows, so no.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #13845 — ilya77@gmail.com — 2004-11-14T16:03:39+00:00

URL: https://externals.io/message/13835#13845 · In reply to: #13844

The *concept* of copying the address space of a process to another
process doesn't exist? How does the Win32 loader work?

Btw, I'm not aware of if the PHP engine is multithreaded, but if it's
possible to run multiple scripts in multiple threads of the same
process, that could do the trick.


> 
> 
> > […]
> 
> The *concept* doesn't exist on Windows, so no.
> 
> 
> 
> Derick
> 
> --
> Derick Rethans
> http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #13846 — Derick Rethans — 2004-11-14T16:05:39+00:00

URL: https://externals.io/message/13835#13846 · In reply to: #13845

> The *concept* of copying the address space of a process to another
> process doesn't exist? How does the Win32 loader work?

No clue - it's not open source you know. But it does NOT fork something.

> Btw, I'm not aware of if the PHP engine is multithreaded, but if it's
> possible to run multiple scripts in multiple threads of the same
> process, that could do the trick.

It's not multi-threaded, nor will it ever be. It's not made for it and
all previous attempts at making this work failed. There is no way.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #13847 — Paul G — 2004-11-14T16:06:29+00:00

URL: https://externals.io/message/13835#13847 · In reply to: #13843

----- Original Message ----- 
From: <ilya77@gmail.com>
To: "Derick Rethans" <derick@php.net>
Cc: "overight" <overight@free.fr>; <internals@lists.php.net>
Sent: Sunday, November 14, 2004 10:55 AM
Subject: Re: [PHP-DEV] php_fork();


> Can't it be emulated?

the semantics of fork() and CreateProcess(), for example, are antirely
different, so no.

p

---

## #13849 — Aaron Wormus — 2004-11-14T20:02:01+00:00

URL: https://externals.io/message/13835#13849 · In reply to: #13844

Derick Rethans wrote:

>
>
>  
>
> > […]
>
>The *concept* doesn't exist on Windows, so no.
>  
>
Perl emulates it pretty nicely on windows

http://www.perldoc.com/perl5.8.4/pod/perlfork.html

Aaron

---

## #13850 — ilya77@gmail.com — 2004-11-14T20:05:16+00:00

URL: https://externals.io/message/13835#13850 · In reply to: #13849

My point exactly.
However, I *know* that perl emulates it using threads.

But, when thinking of it, Cygwin emulates fork() by copying the
address space of a process to a newly created process. It's a bit
slow, but at least it works.

Guess getting into the kernel mode driver land to create *actual*
fork() on win32 is a bit beyond php development.


> Derick Rethans wrote: 
> 

 
> Can't it be emulated?
 The *concept* doesn't exist on Windows, so no.
 Perl
> emulates it pretty nicely on windows
> 
> http://www.perldoc.com/perl5.8.4/pod/perlfork.html
> 
> Aaron

---

## #13852 — Wez Furlong — 2004-11-15T00:25:09+00:00

URL: https://externals.io/message/13835#13852 · In reply to: #13850

> My point exactly.
> However, I *know* that perl emulates it using threads.

Which we don't support.
 
> But, when thinking of it, Cygwin emulates fork() by copying the
> address space of a process to a newly created process. It's a bit
> slow, but at least it works.

and is buggy.
 
> Guess getting into the kernel mode driver land to create *actual*
> fork() on win32 is a bit beyond php development.

Services for Unix does this kind of thing; it's buggy too.

It would be cool to have better threading support and perhaps emulated
fork (it's not something I would use), but I can't see it happening
without some funding behind it.

--Wez.

---

## #13854 — ilya77@gmail.com — 2004-11-15T00:28:45+00:00

URL: https://externals.io/message/13835#13854 · In reply to: #13852

Heh, ActiveState did it after they received funding from Microsoft.
Guess that's not gonna happen with PHP. Ever.



> 
> > […]
> 
> Which we don't support.
> 
> > […]
> 
> and is buggy.
> 
> > […]
> 
> Services for Unix does this kind of thing; it's buggy too.
> 
> It would be cool to have better threading support and perhaps emulated
> fork (it's not something I would use), but I can't see it happening
> without some funding behind it.
> 
> --Wez.

---

## #13855 — Wez Furlong — 2004-11-15T00:32:17+00:00

URL: https://externals.io/message/13835#13855 · In reply to: #13854

If they paid me (or the company I work for) to do it, I would.


> Heh, ActiveState did it after they received funding from Microsoft.
> Guess that's not gonna happen with PHP. Ever.
