Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: Re: File descriptors open info Message-ID: <1991Feb27.182408.28837@athena.mit.edu> Date: 27 Feb 91 18:24:08 GMT References: <1991Feb26.213145.26540@batcomputer.tn.cornell.edu> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 25 I assume that you mean you want to find out from outside the particular process. If you're inside it, you can do something like run fchmod or fstat on each file descriptor and count the number that succeed -- that's the number of valid file descriptors for that process (well, actually, you have to add to that the number that fail because of errors other than EBADF). From outside the process, you have to grovel in kernel memory, although some flavors of Unix provide things like /dev/proc that allow you access to a device that you can pull process information from. I think SunOS has a library of function calls whose names start with kvm_ that allow you to dig around the kernel. A good way to find out how to do this on many different systems would probably be to get your hands on the source code for "ofiles" and stare at it for a while. Ofiles does this, so you should be able to figure out how. Ofiles is available in volume 18 of the comp.sources.unix archives (make sure you get ofiles,new, not ofiles). -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710