From owner-freebsd-hackers@freebsd.org Thu Jan 21 16:25:31 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 4D8E0A8BE42 for ; Thu, 21 Jan 2016 16:25:31 +0000 (UTC) (envelope-from joerg@britannica.bec.de) Received: from mo6-p00-ob.smtp.rzone.de (mo6-p00-ob.smtp.rzone.de [IPv6:2a01:238:20a:202:5300::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.smtp.rzone.de", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E547414C2 for ; Thu, 21 Jan 2016 16:25:30 +0000 (UTC) (envelope-from joerg@britannica.bec.de) X-RZG-AUTH: :JiIXek6mfvEEUpFQdo7Fj1/zg48CFjWjQuEfXeSt/nWoxdY2dvuAIbsw5PvjGQjhWhvF+WPguU+l2DvPiI9bZgofE2TB X-RZG-CLASS-ID: mo00 Received: from britannica.bec.de (p20030057E21B0F000D66165F6FDDE357.dip0.t-ipconnect.de [IPv6:2003:57:e21b:f00:d66:165f:6fdd:e357]) by smtp.strato.de (RZmta 37.15 AUTH) with ESMTPSA id 3058b5s0LGPS8sm (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Thu, 21 Jan 2016 17:25:28 +0100 (CET) Date: Thu, 21 Jan 2016 17:25:27 +0100 From: Joerg Sonnenberger To: Diane Bruce Cc: "Batutis, Ed" , "freebsd-hackers@freebsd.org" Subject: Re: get number of open files in a process? Message-ID: <20160121162527.GA11600@britannica.bec.de> Mail-Followup-To: Diane Bruce , "Batutis, Ed" , "freebsd-hackers@freebsd.org" References: <20160121153636.GA10961@britannica.bec.de> <20160121161637.GA83843@night.db.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160121161637.GA83843@night.db.net> 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: Thu, 21 Jan 2016 16:25:31 -0000 On Thu, Jan 21, 2016 at 11:16:37AM -0500, Diane Bruce wrote: > On Thu, Jan 21, 2016 at 04:36:36PM +0100, Joerg Sonnenberger wrote: > > On Thu, Jan 21, 2016 at 01:34:18PM +0000, Batutis, Ed wrote: > > > I need to determine the number of open files in my process - all types of file handles total - sockets, files, everything. > > > > Use getdtablesize() to get the current largest known fd. If you want, > > you can afterwards loop and use fcntl with F_GETFD to check if the > > descriptor is still open. > > Better off using getrlimit(2) I don't think the current process limit has any direct relation to the maximal open file descriptor. Joerg