delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/05/29/19:45:44

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.3 required=5.0 tests=AWL,BAYES_50,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY
X-Spam-Check-By: sourceware.org
X-Yahoo-SMTP: jenXL62swBAWhMTL3wnej93oaS0ClBQOAKs8jbEbx_o-
Date: Sun, 29 May 2011 19:38:42 -0400
From: Christopher Faylor <cgf-use-the-mailinglist-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Problem with Cygwin's fdopen and Windows handles
Message-ID: <20110529233841.GC5283@ednor.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <loom DOT 20110529T133128-564 AT post DOT gmane DOT org>
MIME-Version: 1.0
In-Reply-To: <loom.20110529T133128-564@post.gmane.org>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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

On Sun, May 29, 2011 at 11:35:03AM +0000, Juanjo wrote:
>Actually there are two different problems related to my implementation of a
>Common Lisp environment, ecl (http://ecls.sf.net)
>
>The first one has to do with fork() not working, due to the fact that ECL
>injects DLLs using dlopen() and they are then improperly loaded. I have seen in
>the mailing list that this is a known problem with no solution so far.
>
>To cope with that problem I had to resort to CreateProcess, a Windows routine
>that allows us to redirect the input/output/error channels of a process as
>needed. The problem I have is that the C streams that result from the Windows
>handle can only be read with read() and not with fread(). This is a problem
>because the ECL environment needs buffered I/O, with locking and so on, and we
>rely on C streams for that.
>
>I attach a small test program that segfaults when using fread() on the stream
>created with fdopen(). notice that read() works.
>
>Any help is really welcome and appreciated.

Unfortunately, cygwin_attach_handle_to_fd doesn't really work.  Cygwin
needs to know the type of handle it is attaching in order to set up
the correct type of file handler.  Since it doesn't do that the handle
is of limited utility.

It is possible for the function to be more intelligent since other parts
of cygwin try to figure out the handle type by querying attributes of the
handle.  So this is a http://cygwin.com/acronyms#SHTDI scenario.

I don't know what you mean by dlopen() causing fork not to work.  That's
obviously not normally the case.  If you are seeing something like this
then maybe your dlls are not properly based to avoid collisions.  If
that is the case then you should change your link line to specify unique
load addresses for each dll.

cgf

--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019