This is the mail archive of the cygwin 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]

Fwd: Bug with dlopen() and fork()


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


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