Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: What is the difference between Windows fork an Unix fork ?

by jbert (Priest)
on Dec 11, 2006 at 10:14 UTC ( #589015=note: print w/ replies, xml ) Need Help??


in reply to What is the difference between Windows fork an Unix fork ?

Outside the world of perl (or cygwin), there isn't a fork on Windows. Unix has two primitives: fork (create new process identical to calling process) and exec (replace details of current process with those loaded from executable file).

Windows has one primitive: CreateProcess, which is roughly equivalent to fork-then-exec.

cygwin works around this with crazy mad black magic1, which manages to emulate fork on windows (slowly). The perlfork doc linked above shows perl's own answer to that (presumably used in Activestate and Strawberry perl but not cygwin).

1: Something like: use CreateProcess to start a compliant, suspended process. Use setjmp to save state, parent copies text and data into waiting child (and setjmp info). Child starts and longjmp's back to saved state. Plus some more shenanigans with copying the stack and heap once the child is running. And probably a lot more. Amazing they ever got it working.


Comment on Re: What is the difference between Windows fork an Unix fork ?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://589015]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2014-09-24 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (243 votes), past polls