From owner-freebsd-hackers Fri Oct 15 5: 9:54 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id 09F2415017 for ; Fri, 15 Oct 1999 05:09:51 -0700 (PDT) (envelope-from des@flood.ping.uio.no) Received: (from des@localhost) by flood.ping.uio.no (8.9.3/8.9.3) id OAA32351; Fri, 15 Oct 1999 14:09:48 +0200 (CEST) (envelope-from des) To: Zhihui Zhang Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Determine # of open files via fdesc References: From: Dag-Erling Smorgrav Date: 15 Oct 1999 14:09:47 +0200 In-Reply-To: Zhihui Zhang's message of "Thu, 14 Oct 1999 16:58:38 -0400 (EDT)" Message-ID: Lines: 29 X-Mailer: Gnus v5.7/Emacs 20.4 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Zhihui Zhang writes: > I do not know whether it is a good idea to determine the number of open > files of a process by enabling fdesc in the kernel. Anyway, I do the > following: > > # mount_fdesc -o union fdesc /dev > # ls -al /dev/fd > list > > cat list > total 1 > crw------- 1 root tty 12, 0 Oct 15 17:09 0 > -rw-r--r-- 1 root wheel 0 Oct 15 17:09 1 > crw------- 1 root tty 12, 0 Oct 15 17:09 2 > drw-r--r-- 5 root wheel 1024 Oct 15 17:09 3 > dr--r--r-- 2 root wheel 512 Oct 15 16:28 4 > > I do not know why 3 and 4 are labeled as directory. 1 was labeled as > character device but is changed probably by the redirection >. I run a > small program to open three files and run forever in the background. After > this, I expect to see three more items under /dev/fd, but there are not. > Can anyone explain this to me? Each process only sees its own file descriptors. The five descriptors you see above belong to ls. 0 (stdin) and 2 (stderr) are whichever tty or pty you typed this into, 1 (stdout) is the file you redirected the output from ls into, 3 is /dev and 4 is /dev/fd. DES -- Dag-Erling Smorgrav - des@flood.ping.uio.no To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message