delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/11/19/07:55:54

From: vischne AT ibm DOT net
Subject: Outsourcing fork() to RTLDLL
19 Nov 1997 07:55:54 -0800 :
Message-ID: <199711191538.PAA91940.cygnus.gnu-win32@out1.ibm.net>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019