Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com Message-ID: <779F20BCCE5AD31186A50008C75D99791716F2@SILLDN_MAIL1> From: "Fifer, Eric" To: cygwin-developers AT sourceware DOT cygnus DOT com Subject: problem with fork/exec in Cygwin DLL called from non-Cygwin EXE Date: Thu, 2 Mar 2000 17:45:49 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" I recently stumbled across a problem that I'm just starting to dig into. For now, all I can really do is describe it and hope for some suggestions. First, here's the example: main.c: #include int main() { HINSTANCE libref; FARPROC symref; void (*func)(); libref = LoadLibraryExA("lib.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH); symref = GetProcAddress(libref, "func1"); func = (void *) symref; func(); exit(0); } lib.c: #include #include #include void func1() { FILE *fp; int status; char buf[512]; fprintf(stderr, "start func1\n"); #if 0 if(fork() == 0) { fprintf(stderr, "child\n"); execl("/bin/cat.exe", "cat", "lib.c", 0); exit(1); } wait(&status); #else fp = popen("cat lib.c", "r"); while(fgets(buf, sizeof(buf), fp)) { fprintf(stderr, "func1: %s", buf); } pclose(fp); #endif fprintf(stderr, "end func1\n"); } Makefile: all: main lib.dll main: main.c gcc -Wall -g -o main -mno-cygwin main.c lib.dll: lib.c gcc -Wall -g -c lib.c dllwrap --export-all --output-def lib.def -o lib.dll lib.o \ --entry __cygwin_noncygwin_dll_entry AT 12 And, you'll need an .xls but all it really contains is a VB stub so you can call func1(): Public Declare Function func1 Lib "\lib.dll" () Given the above code this is what I'm seeing: + main.exe, lib.c fork/exec: Seems to work fine, but a very long delay until the cat finishes. + main.exe, lib.c popen: Basically works, but get this message: 0 [proc] main 30311 wait_subproc: wait failed. nchildren 1, wait 500, Win32 error 6 8135 [proc] main 30311 wait_subproc: event[1] 0x94, Win32 error 6 + excel.exe, lib.c fork/exec: + excel.exe, lib.c popen: Same in both these cases, you get a second Excel instance (first is paused) and when you close the second Excel you get this message and the first Excel dies too: 0 [main] excel 30304 sync_with_child: child 528(0x1C0) died before initialization with status code 0x0 5866 [main] excel 30304 sync_with_child: *** child state waiting for longjmp 8769 [sig] excel 30304 stackdump: Dumping stack trace to excel.exe.stackdump Any thoughts on what is happening here? I'm using the Feb-28 snapshot. Thanks. Eric Fifer