Tuesday, February 6, 2007

Emulation of Fork in Windows OS

The less we know, the better we sleep!

It is terrible:
Set up a pid in the shared memory area for the new child. Use setjmp() to capture state. First time (parent), set up some stuff and use CreateProcess to run a second copy of the same executable. The second copy will note in the shared memory area that it's a fork, and do the longjmp. They sync up and the parent copies all it's program memory to the child's address space. There's also code to reload dlls, map shared memory and mmap'd files, etc.

No comments:

Post a Comment