From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Cedric Cellier Newsgroups: gmane.lisp.guile.user Subject: sharing a file descriptor with a port Date: Fri, 17 Sep 2010 11:30:46 +0200 Message-ID: <20100917093046.GA32484@securactive.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1284715880 9122 80.91.229.12 (17 Sep 2010 09:31:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 17 Sep 2010 09:31:20 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Sep 17 11:31:19 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OwXHr-0000BN-5i for guile-user@m.gmane.org; Fri, 17 Sep 2010 11:31:19 +0200 Original-Received: from localhost ([127.0.0.1]:47162 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OwXHq-000366-IV for guile-user@m.gmane.org; Fri, 17 Sep 2010 05:31:18 -0400 Original-Received: from [140.186.70.92] (port=49418 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OwXHi-00034f-Ds for guile-user@gnu.org; Fri, 17 Sep 2010 05:31:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OwXHd-0000HW-7O for guile-user@gnu.org; Fri, 17 Sep 2010 05:31:10 -0400 Original-Received: from smtp5-g21.free.fr ([212.27.42.5]:51098) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OwXHc-0000Cz-L5 for guile-user@gnu.org; Fri, 17 Sep 2010 05:31:05 -0400 Original-Received: from apc.happyleptic.org (unknown [82.67.194.89]) by smtp5-g21.free.fr (Postfix) with ESMTP id 91809D48110 for ; Fri, 17 Sep 2010 11:30:42 +0200 (CEST) Original-Received: from ccellier.rd.securactive.lan (extranet.securactive.org [82.234.213.170]) by apc.happyleptic.org (Postfix) with ESMTP id 6A22633812 for ; Fri, 17 Sep 2010 11:41:25 +0200 (CEST) Original-Received: from rixed by ccellier.rd.securactive.lan with local (Exim 4.71) (envelope-from ) id 1OwXHK-0000W0-Bj for guile-user@gnu.org; Fri, 17 Sep 2010 11:30:46 +0200 Mail-Followup-To: Cedric Cellier , guile-user@gnu.org Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8170 Archived-At: Support I open a file, then make a port with the file description (with scm_fdopen), then I close the file description. When the port will be garbage collected the GC will attempt to close the port->fdes, ignoring the EBADF error, so everything is OK. Now supose I do this in a loop. The next open will probably return me the same fd number. If the GC is triggered now, the previous port might be collected and it's fdes closed, thus closing my new file ! To circumvent this problem I was setting the revealed count to 1, but then the port are no more garbage collected. I can't find a way out of this trap, so I'm looking for a way to either force the garbage collection of a given port when I know that it's safe to close the port, or a way to reset port->fdes to -1 so that the destruction of this port in the future won't lead to a close. So now I'm planning to never close my files and let the GC do this, but this causes all kind of problems (apart from fdes exhaustion, some other programs use the close of these files as a trigger to some processing...) Any idea someone ?