From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: rixed@happyleptic.org Newsgroups: gmane.lisp.guile.user Subject: Re: debugging guile runtime Date: Wed, 31 Aug 2011 09:38:22 +0200 Message-ID: <20110831073822.GB22646@yeeloong.happyleptic.org> References: <20110829125030.GB30079@ccellier.rd.securactive.lan> <20110829162400.GB21699@ccellier.rd.securactive.lan> <87y5ycowh3.fsf@ambire.localdomain> <20110830105642.GA16079@ccellier.rd.securactive.lan> <87wrduhp1x.fsf@gnu.org> <20110830162527.GA20481@ccellier.rd.securactive.lan> <8739gio7u0.fsf@inria.fr> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1314776381 7949 80.91.229.12 (31 Aug 2011 07:39:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 31 Aug 2011 07:39:41 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Aug 31 09:39:37 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QyfOb-0002JF-AI for guile-user@m.gmane.org; Wed, 31 Aug 2011 09:39:37 +0200 Original-Received: from localhost ([::1]:54664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QyfOV-0005Sb-Iw for guile-user@m.gmane.org; Wed, 31 Aug 2011 03:39:31 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:58371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QyfOR-0005SG-OJ for guile-user@gnu.org; Wed, 31 Aug 2011 03:39:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QyfOQ-0005vd-H5 for guile-user@gnu.org; Wed, 31 Aug 2011 03:39:27 -0400 Original-Received: from smtp5-g21.free.fr ([212.27.42.5]:57103) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QyfOP-0005uo-RS for guile-user@gnu.org; Wed, 31 Aug 2011 03:39:26 -0400 Original-Received: from yeeloong (unknown [82.67.194.89]) by smtp5-g21.free.fr (Postfix) with SMTP id 66894D4806C for ; Wed, 31 Aug 2011 09:39:18 +0200 (CEST) Original-Received: by yeeloong (sSMTP sendmail emulation); Wed, 31 Aug 2011 09:38:22 +0200 Mail-Followup-To: rixed@happyleptic.org, guile-user@gnu.org Content-Disposition: inline In-Reply-To: <8739gio7u0.fsf@inria.fr> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 212.27.42.5 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8755 Archived-At: > > (BTW, if anyone knows the rational behind this, I would be glad to > > know). > > When typing ???foo 2< baz 5> bar??? in a shell, the shell first forks, the > opens/dups 2 and 5, and finally execs ???foo???, which gets to see 2 and 5 > as open FDs. Yes, the shell can open/dup the file additional files you explicitly ask for, but the point is that it will nonetheless closes the file descriptors it is using itself. For instance my shell is using these files : $ ls -l /proc/$(pidof zsh)/fd lrwx------ 1 rixed rixed 64 Aug 31 09:25 0 -> /dev/tty1 lrwx------ 1 rixed rixed 64 Aug 31 09:25 1 -> /dev/tty1 lrwx------ 1 rixed rixed 64 Aug 31 09:25 10 -> /dev/tty1 lr-x------ 1 rixed rixed 64 Aug 31 09:25 11 -> /debian/home/rixed/.zshenv lr-x------ 1 rixed rixed 64 Aug 31 09:25 12 -> /debian/home/rixed/.profile lrwx------ 1 rixed rixed 64 Aug 31 09:25 2 -> /dev/tty1 but the children it execs do not come with files 10, 11 and 12 opened. So this is my understanding that when the shell exec a command it closes all but the required files between fork and exec, while popen do not. This is getting off-topic, though. > > Except that, as previously discussed in another thread, there is no easy > > way to do that between the fork and the exec (since I don't want to > > actually close these files in the main program that starts the pipe). > > Hmm right. We???d need to insert a hook in ???open-pipe??? so that, when this > behavior is wanted, one can actually close those FDs. If I'm the only one concerned then I can (and actually already did) handle the issue using the close-on-exec flag (as was suggested to me on this list when I raised the problem initially). I'm much more interested in working to solve the FD_SETSIZE limit and/or the ports thread safety issue. :-)