www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/10/30/06:02:42

From: cgf AT bbc DOT com (Chris Faylor)
Subject: Re: cygwin.dll src question: fork()
30 Oct 1997 06:02:42 -0800 :
Message-ID: <199710301332.IAA00645.cygnus.gnu-win32@hardy.bbc.com>
To: newsham AT lava DOT net
Cc: gnu-win32 AT cygnus DOT com

>> >At the time when cygwin_fork_helper1() returns isn't the
>> >child's state already a copy of the parent's state?
>> 
>> No, actually, it isn't.  The setjmp and longjmp are used to move the
>> current execution point into the appropriate point in the cygwin_fork_helper1
>> function to emulate a true UNIX fork().
>> 
>> What happens is that to emulate a fork, the parent process starts the
>[...]
>> extends the stack to hopefully insure that the stack is large enough to
>> duplicate the parent, and longjmps to the child portion of the
>> cygwin_fork_helper1 routine.  There it wakes up the parent and sleeps
>> itself.
>
>um..  this is a completely different setjmp/longjmp pair.
>The setjmp that is jumped to from crt0 is in the cygwin_fork_helper1()
>function.  The __fork() function has its own setjmp/longjmp
>pair that seems to add no extra functionality.  Perhaps some sort
>of legacy from fork implementations of past.

My sincere apologies.  I've committed the usual Usenet sin of answering
the question that wasn't asked.

On inspection of the __fork code, I understand your confusion and share
it.  I wonder if this is a holdover from a previous fork implementation
or if this assures stack synchronization in some arcane way.
--
http://www.bbc.com/	cgf AT bbc DOT com			"Strange how unreal
VMS=>UNIX Solutions	Boston Business Computing	 the real can be."
-
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