This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Outsourcing fork() to RTLDLL


Actually, the trick to simulating fork() under Windows is to program a
multi-threaded version of <setjmp.h> in which `longjmp(env, rval)' keeps
the stack of the thread calling it, copying any things necessary to
simulate the longjmp calling environment onto that stack.

This is because the Windows version of a thread involves a function, not a
region of code in a parent process.  So, the `thread' function can't
return to the parent process.  The best it can do is to longjmp back to
the code implementing fork().

Then, of course, a Windows process is an entire program and is created by
CreateProcess, which means that Linux getpid() has to be implemented as a
call to GetCurrentThreadID().

Come to think of it, wasn't it OS/2 that originally got us into this mess?
Windows 95/NT is just a belated OS/2 implementation.




-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]