From owner-freebsd-hackers@freebsd.org Fri Jan 22 14:41:12 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4AAE6A8D3A1 for ; Fri, 22 Jan 2016 14:41:12 +0000 (UTC) (envelope-from db@db.net) Received: from diana.db.net (unknown [IPv6:2620:64:0:1:223:7dff:fea2:c8f2]) by mx1.freebsd.org (Postfix) with ESMTP id 36FA715D8 for ; Fri, 22 Jan 2016 14:41:12 +0000 (UTC) (envelope-from db@db.net) Received: from night.db.net (localhost [127.0.0.1]) by diana.db.net (Postfix) with ESMTP id 647332AA45F; Fri, 22 Jan 2016 07:40:39 -0700 (MST) Received: by night.db.net (Postfix, from userid 1000) id 1A0EF1CC4F; Fri, 22 Jan 2016 09:41:02 -0500 (EST) Date: Fri, 22 Jan 2016 09:41:02 -0500 From: Diane Bruce To: Mateusz Guzik , Jilles Tjoelker , "Batutis, Ed" , "freebsd-hackers@freebsd.org" , Diane Bruce , Joerg Sonnenberger Subject: Re: get number of open files in a process? Message-ID: <20160122144102.GA92956@night.db.net> References: <20160121153636.GA10961@britannica.bec.de> <20160121161637.GA83843@night.db.net> <20160121162527.GA11600@britannica.bec.de> <20160121191308.GA21869@dft-labs.eu> <31126442b7d347c5976a57aabc2e5792@hioexcmbx08-prd.hq.netapp.com> <20160121224511.GA74045@stack.nl> <20160121225111.GB21869@dft-labs.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160121225111.GB21869@dft-labs.eu> User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jan 2016 14:41:12 -0000 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 > Diane -- - db@FreeBSD.org db@db.net http://www.db.net/~db