This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Fwd: Bug with dlopen() and fork()
- From: Jaime Fabregas Fernandez <jaime dot fabregas at tarlogic dot com>
- To: cygwin at cygwin dot com
- Date: Wed, 19 Feb 2014 14:38:52 +0100
- Subject: Fwd: Bug with dlopen() and fork()
- Authentication-results: sourceware.org; auth=none
- References: <CAMzR4E63GYJPeNx27vpX5kBAFbrXDtS0k81pi5=SfKAV8fQteA at mail dot gmail dot com>
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