9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Charles Forsyth <charles.forsyth@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] file descriptor leak
Date: Tue, 16 Feb 2016 17:17:33 +0000	[thread overview]
Message-ID: <CAOw7k5jqj5Ms9HxWCPS+amRMbKkC-a8YdktxwERZbVRYQkbjaQ@mail.gmail.com> (raw)
In-Reply-To: <c9ad3cef0cf11a2ea579f3a9d757d6b1@proxima.alt.za>

[-- Attachment #1: Type: text/plain, Size: 1278 bytes --]

On 16 February 2016 at 16:42, <lucio@proxima.alt.za> wrote:

> Then, it would be tempting to take the
>
>         dup(fd,0); close(fd);
>
> out to before the if(pid==0)...
>

the idea is to have fd (/dev/null in this case) be standard input in the
new process,
so it needs to follow the pid==0 test.

the "outside" command is one that wasn't distributed (I assume it bound a
separate #I interface
on /net.alt and set it up), so the code currently probably doesn't do
anything useful elsewhere.


> probably the file descriptor leak comes from dnresolve.c


you can cat /proc/$dnspid/fd
where dnspid is the process id one or more of the active dns processes,
to see which files are open, after the message appears.
if there are many /dev/null open, that suggests your idea was right.

i think you're right that it leaks an fd to /dev/null in that system call,
so
it should instead open /dev/null separately and assign fd before the call
and close it afterwards.

even so, i wonder if that's really what's happening in every case of "more
than N fds", because
the call to outside is only needed in the case that the udp under /net.alt
is being
used and an open there has failed. still, looking at the /proc/N/fd file
should help decide that.

[-- Attachment #2: Type: text/html, Size: 2588 bytes --]

  parent reply	other threads:[~2016-02-16 17:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 15:52 arisawa
2016-02-16 15:56 ` Jacob Todd
2016-02-16 16:42   ` lucio
2016-02-16 17:05     ` Jacob Todd
2016-02-16 17:17     ` Charles Forsyth [this message]
2016-02-16 18:01 ` cinap_lenrek
2016-02-16 21:05   ` erik quanstrom
2016-02-16 21:16   ` Charles Forsyth
2016-02-17  2:19     ` cinap_lenrek
2016-02-22  5:18     ` erik quanstrom
2016-02-16 22:24 ` Charles Forsyth
2016-02-17  1:13   ` arisawa
2016-02-17  1:22     ` cinap_lenrek

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

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

  git send-email \
    --in-reply-to=CAOw7k5jqj5Ms9HxWCPS+amRMbKkC-a8YdktxwERZbVRYQkbjaQ@mail.gmail.com \
    --to=charles.forsyth@gmail.com \
    --cc=9fans@9fans.net \
    /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 NNTP newsgroup(s).