Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!ames!oliveb!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.unix.wizards Subject: Re: Determining the max number of open files on System V Message-ID: <20117@sun.uucp> Date: Mon, 1-Jun-87 15:39:24 EDT Article-I.D.: sun.20117 Posted: Mon Jun 1 15:39:24 1987 Date-Received: Wed, 3-Jun-87 01:39:26 EDT References: <3635@spool.WISC.EDU> Sender: news@sun.uucp Lines: 37 Keywords: NOFILES, S5R3 Summary: UNIX documentation is a contradiction in terms > I'm trying to port a program from BSD to Sys V Rel. 3. Along the way, > it tries to close all of its file descriptors. On BSD you just call > getdtablesize() to find how many to close, but I can't seem to find > the equivalent on S5R3. > > So, where do I get the real value? What is "v.v_nofiles" and how do > I get at it's value? You do ulimit(4, 0L); and the returned value is the maximum number of file descriptors. Or, preferably, you do int getdtablesize() { extern long ulimit(); return (ulimit(4, 0L)); } and obviate the need to fix all occurrences of "getdtablesize". No, this isn't documented. It seems AT&T is maintaining the proud "use the Force, read the Source" tradition of earlier UNIX releases.... (They also seem to be maintaining the equally proud "different for its own sake" or "Not Invented Here" tradition; why the hell couldn't they have added a "getdtablesize" system call, or even just supplied a wrapper around "ulimit"? Whether they like it or not, "getdtablesize" is as close as you can get to a *de facto* standard name for the routine that returns the size of the per-process file table.) Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com