This is the mail archive of the cygwin-developers 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]
Other format: [Raw text]

Forking Win32 process?


Having read the FAQ chapter "How do I use cygwin1.dll with Visual
Studio or MinGW"
(http://www.cygwin.com/faq/faq-nochunks.html#faq.programming.msvs-mingw)
I am trying to load cygwin1.dll and then call fork(). This is not
going to work: it creates the child process but then hangs somewhere
inside cygwin1.dll. As the docs didn't tell it's impossible I
suspected my own error and spent a significant amount of time trying
to make it work. Several problems were found:

- the FAQ statement "Make sure you have 4K of scratch space at the
bottom of your stack" is simply wrong. You have to reserve at least
CYGTLS_PADSIZE (currently 12700 bytes) in the bottom of the stack.
Also they cannot be reserved at the very bottom - several hundred
bytes (300 or so) are taken by the CRT data. If it's OK it should be
explained somethere (in the FAQ or in cygload sources)

- even current cygload utility works somewhat incorrectly in my system
(WinXP). It does not hang or generate access violation (all cygwin
function succeed in debugger), but all output after loading
cygwin1.dll goes to nowhere, i.e. "Initializing cygwin..." is the last
message I see on the screen.

OK, but I needed fork(). I tried almost everything, even switching
stack (changing TIB) - nothing helped. And finally I found the
following message from Christopher Faylor of December, 2000:

http://sources.redhat.com/ml/cygwin/2000-12/msg00366.html
[...]
You need to call "cygwin_dll_init" (via GetProcAddress of course) prior
to using any cygwin functions.  This function takes no arguments.

This doesn't mean that you'll be able to call every single cygwin
function.  Some, like fork() won't work.
[...]

Ah, is it up-to-date info and fork() really doesn't work with the
current cygwin? If so, why this is not mentioned in the docs or
somewhere? Is it really impossible from the technical point of view?

- Dmitry Bely


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