Fwd: Bug with dlopen() and fork()
Jaime Fabregas Fernandez
jaime.fabregas@tarlogic.com
Wed Feb 19 14:15:00 GMT 2014
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.
Thanks
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list