From owner-freebsd-hackers@freebsd.org Thu Jan 21 15:36:42 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 27E48A8A9DF for ; Thu, 21 Jan 2016 15:36:42 +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 C24E111CD for ; Thu, 21 Jan 2016 15:36:41 +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 j056bcs0LFabpNI (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 16:36:37 +0100 (CET) Date: Thu, 21 Jan 2016 16:36:36 +0100 From: Joerg Sonnenberger To: "Batutis, Ed" Cc: "freebsd-hackers@freebsd.org" Subject: Re: get number of open files in a process? Message-ID: <20160121153636.GA10961@britannica.bec.de> Mail-Followup-To: "Batutis, Ed" , "freebsd-hackers@freebsd.org" References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 15:36:42 -0000 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. Joerg