Date: 15 Oct 1999 14:09:47 +0200 From: Dag-Erling Smorgrav <des@flood.ping.uio.no> To: Zhihui Zhang <zzhang@cs.binghamton.edu> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Determine # of open files via fdesc Message-ID: <xzpg0zcvn90.fsf@flood.ping.uio.no> In-Reply-To: Zhihui Zhang's message of "Thu, 14 Oct 1999 16:58:38 -0400 (EDT)" References: <Pine.GSO.3.96.991014164954.3631B-100000@sol.cs.binghamton.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
Zhihui Zhang <zzhang@cs.binghamton.edu> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpg0zcvn90.fsf>