delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:subject:message-id:reply-to | |
:references:mime-version:content-type:in-reply-to; q=dns; s= | |
default; b=ArzBM3O0NrwE5pKHERIxbBzUlv/KwjOXa4TfIuNc0LPVsY4225DWM | |
FyaACn27tGAzVIcyaBGLADi9nXRg+DXVq/qQaeMUctwujRQp/NdsN3F00LrbWDTr | |
5RAUbkifs90IisyVfpfeEwovW1RfjRkTe0v+d3RAe06PzQlCZVkqk8= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:subject:message-id:reply-to | |
:references:mime-version:content-type:in-reply-to; s=default; | |
bh=AzAmnR2yagVIylAOwdWIXJ6vssM=; b=f3wRcrHVztL+hI4xK5SpwHnK1MXF | |
uSeqfW2kxK/tIOFxSBAtnevBrariu48rnNB7nIyhVFgxvsn8jKUk1Soz3bFtYlfq | |
efU/aZmtXnqepXRwx/yC4rbOylG7ZI8k0Z0vQsozxJDtpdzaXVUlVsefFxJWBXnF | |
NYsWo5h16Ix3fLU= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=-5.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 |
X-HELO: | calimero.vinschen.de |
Date: | Wed, 19 Feb 2014 19:46:48 +0100 |
From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: Bug with dlopen() and fork() |
Message-ID: | <20140219184648.GW2246@calimero.vinschen.de> |
Reply-To: | cygwin AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
References: | <CAMzR4E63GYJPeNx27vpX5kBAFbrXDtS0k81pi5=SfKAV8fQteA AT mail DOT gmail DOT com> <CAMzR4E4jeO45W5wn4ehdwTaZ_gSKPrrEV49OjnfWwjAj3k0ZDg AT mail DOT gmail DOT com> |
MIME-Version: | 1.0 |
In-Reply-To: | <CAMzR4E4jeO45W5wn4ehdwTaZ_gSKPrrEV49OjnfWwjAj3k0ZDg@mail.gmail.com> |
User-Agent: | Mutt/1.5.21 (2010-09-15) |
--8MWQa5Xlpje7WrDu Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > I've searched for a similar problem in the mailing lists and found > this unanswered thread from 2001: >=20 > http://cygwin.com/ml/cygwin/2001-02/msg01225.html >=20 >=20 > I'm running cygwin64. This behaviour can be checked with the following > test program: >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D > #include <stdio.h> > #include <dlfcn.h> >=20 > int (*myopen)(const char *); >=20 > main(){ > void *handle; > int ret; > handle =3D dlopen("my_lib.dll", RTLD_LAZY); > myopen =3D dlsym(handle, "mylib_open"); >=20 > if( ! fork() ){ > ret =3D myopen(""); > printf("This printf never shows, call to myopen will > block for ever\n"); > } > else{ > ret =3D myopen(""); > printf("%i\n", ret); > sleep(1); > } > } > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D >=20 > Same program runs correctly (showing the two printf's) in a Linux environ= ment. 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 --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --8MWQa5Xlpje7WrDu Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJTBPwYAAoJEPU2Bp2uRE+g3EYP/juWSBwGtFip35D0MUuJfdRi T6RoqQi9SjNFVez4FfE6OYzpWwyCCvkrIE0/wYAldf++sXlNB0JjVrNzz2/6O8FD nLfe5FeajOu8GSD8eKD11bUJUuwxvYMtAMWd/UMquvRXciJCjWjrS4GeJNlk/VO3 Awe13C4NANXhA9OlAdMN9Ok7SXvlLkn8ZL2esFZHHZscpH3vDeuZiIA+iJ5HFcys f0KwXK/2+NCv7EPq8xs629842qeUbwNlO2IVUkIBuqPpxce1cLEaPhXIYRpI2kRG pu/sFaLQjq8r5jRb0Y0IEQ+uus9K9hB2Z7tq5orafGNt1Qh2wX98j9m8NThrEvGE HWRY4bfFOzKIlsYM+EnaMlyHYSJOzDHg8rSpcVbAuIlKlQsia10by48vb+C210z3 M9REywBFUkCI/pHVepfqrdBy+StZ9c8JXmqfRoEFO68j+OmDg+8eibSk9n8qvwHS 2BOAS25SwYkHTAVy8tFOW+wxSTKrkDYu2/olPJcAxT6rnuSaHQa3iGfFVU3ZnelU 14Dqfg6qiRmx+9hqAl+GOtutbkDiEawAGlbQhERFH05asgDNN6k699Go3Ti8JYBa ODlzYpoG12NI9gN6ZyNsBSQRyBZKEThArUofhUgiG84pTypi/ec3VtdGfgrfxtJ4 +1X5QfSjRJRqDQhocPj4 =ajF3 -----END PGP SIGNATURE----- --8MWQa5Xlpje7WrDu--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |