On Feb 19 14:38, Jaime Fabregas Fernandez wrote: > Library references loaded by a process using dlopen() and dlsym() are > no more valid in child processes after running a fork(). Calls from > child process will never return. > > I've searched for a similar problem in the mailing lists and found > this unanswered thread from 2001: > > http://cygwin.com/ml/cygwin/2001-02/msg01225.html > > > I'm running cygwin64. This behaviour can be checked with the following > test program: > > ======================================================== > #include <stdio.h> > #include <dlfcn.h> > > int (*myopen)(const char *); > > main(){ > void *handle; > int ret; > handle = dlopen("my_lib.dll", RTLD_LAZY); > myopen = dlsym(handle, "mylib_open"); > > if( ! fork() ){ > ret = myopen(""); > printf("This printf never shows, call to myopen will > block for ever\n"); > } > else{ > ret = myopen(""); > printf("%i\n", ret); > sleep(1); > } > } > ======================================================== > > Same program runs correctly (showing the two printf's) in a Linux environment.
Works for me with 64 bit Cygwin. I used this as DLL: $ cat > my_lib.c <<EOF int mylib_open (const char *foo) { return 1; } $ gcc -shared -o my_lib.dll my_lib.c $ gcc -g -o my_tst my_tst.c <- That's your above testcase $ uname -a CYGWIN_NT-6.3 vmbert8164 1.7.28(0.271/5/3) 2014-02-04 16:01 x86_64 Cygwin $ ./my_tst 1 This printf never shows, call to myopen will block for ever $ Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat
pgpE4jjgmhJB7.pgp
Description: PGP signature