unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: rixed@happyleptic.org
To: guile-user@gnu.org
Subject: Re: debugging guile runtime
Date: Wed, 31 Aug 2011 09:38:22 +0200	[thread overview]
Message-ID: <20110831073822.GB22646@yeeloong.happyleptic.org> (raw)
In-Reply-To: <8739gio7u0.fsf@inria.fr>

> > (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. :-)




  reply	other threads:[~2011-08-31  7:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-29 12:50 debugging guile runtime rixed
2011-08-29 14:35 ` Nala Ginrut
2011-08-29 16:24   ` rixed
2011-08-29 19:20     ` Thien-Thi Nguyen
2011-08-30 10:56       ` rixed
2011-08-30 15:55         ` Ludovic Courtès
2011-08-30 16:25           ` rixed
2011-08-30 22:25             ` Ludovic Courtès
2011-08-31  7:38               ` rixed [this message]
2011-08-31 21:10             ` Andy Wingo
2011-08-31 21:07 ` Andy Wingo
2011-09-01 11:32   ` rixed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110831073822.GB22646@yeeloong.happyleptic.org \
    --to=rixed@happyleptic.org \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).