Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Jan 2016 23:45:11 +0100
From:      Jilles Tjoelker <jilles@stack.nl>
To:        "Batutis, Ed" <Ed.Batutis@netapp.com>
Cc:        Mateusz Guzik <mjguzik@gmail.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:  <20160121224511.GA74045@stack.nl>
In-Reply-To: <31126442b7d347c5976a57aabc2e5792@hioexcmbx08-prd.hq.netapp.com>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jan 21, 2016 at 07:44:01PM +0000, Batutis, Ed wrote:
> > However, the real question is what do you need this for.

> I would like to know when I am getting close to hitting the file
> handle limit. This is useful for two reasons: 1) if I run out of
> available file handles this will most likely cause my process to
> crash. If I start logging when the count begins to get dangerously
> high, then I might after the fact be able to determine what was going
> on to cause that. 2) Some handles are used by a user interface. It
> would be nice if the server could reject connections when the open
> handle count hit a critical threshold so the user interface doesn't
> become part of the problem - obscuring the actual underlying cause.

You can check the integer file descriptor that was just created, since
if the descriptor is N, at least N other descriptors must be active at
the same time. For example, if a new client's file descriptor is higher
than the limit minus some safety margin, reject the connection.

-- 
Jilles Tjoelker



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