Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Jan 2016 09:41:02 -0500
From:      Diane Bruce <db@db.net>
To:        Mateusz Guzik <mjguzik@gmail.com>, Jilles Tjoelker <jilles@stack.nl>, "Batutis, Ed" <Ed.Batutis@netapp.com>, "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>, Diane Bruce <db@db.net>, Joerg Sonnenberger <joerg@britannica.bec.de>
Subject:   Re: get number of open files in a process?
Message-ID:  <20160122144102.GA92956@night.db.net>
In-Reply-To: <20160121225111.GB21869@dft-labs.eu>
References:  <ea9f2ab2d4f543c8ad34fdeb082f8c7a@hioexcmbx08-prd.hq.netapp.com> <20160121153636.GA10961@britannica.bec.de> <20160121161637.GA83843@night.db.net> <20160121162527.GA11600@britannica.bec.de> <d26cc2fcea304ea6a89f61c2ec497322@hioexcmbx08-prd.hq.netapp.com> <20160121191308.GA21869@dft-labs.eu> <31126442b7d347c5976a57aabc2e5792@hioexcmbx08-prd.hq.netapp.com> <20160121224511.GA74045@stack.nl> <20160121225111.GB21869@dft-labs.eu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jan 21, 2016 at 11:51:11PM +0100, Mateusz Guzik wrote:
> On Thu, Jan 21, 2016 at 11:45:11PM +0100, Jilles Tjoelker wrote:
> > On Thu, Jan 21, 2016 at 07:44:01PM +0000, Batutis, Ed wrote:
...
> 
> This cannot work. POSIX mandates the lowest free fd is returned, so the
> N you see here can be extremely low, while the process is running out of
> fds.

The hack not mentioned here of course is to (mis-)use dup2() to shuffle
all your other fd's down by one as you close them. ;)

(This actually was used in early versions of the IRC Daemon. ;)
 Not for this reason however. )

> one to take - you have to have a very big reserve to not suddenly run
> out of fds, one would just limit amount of clients and, well, handle
> errors as they can pop up for reasons other than running out of fd slots.

I agree.

> 
> -- 
> Mateusz Guzik <mjguzik gmail.com>
> 

Diane
-- 
- db@FreeBSD.org db@db.net http://www.db.net/~db



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160122144102.GA92956>