Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!sdd.hp.com!hp-pcd!hpfcso!hpfcdc!rsh From: rsh@hpfcdc.HP.COM (Scott Holbrook) Newsgroups: comp.sys.hp Subject: Re: The "getdtablesize" command Message-ID: <5570555@hpfcdc.HP.COM> Date: 21 Dec 90 18:11:21 GMT References: <28687@mimsy.umd.edu> Organization: HP Fort Collins, Co. Lines: 45 >> Try: >> >> #include >> >> #ifdef hpux >> t = FD_SETSIZE; >> #else /* hpux */ >> t = getdtablesize(); >> #endif /* hpux */ > Art Harkin > Hewlett Packard > How come that _no_one_ in the world, not even HP, uses its own system > call to do this ? (sysconf, a solution with which I posted a few days > ago). The sysconf() solution is the preferred method. However, the submitter stated that he was running on a HP-UX 3.1 system, which did not support the sysconf(_SC_OPEN_MAX) call. So, your proposed solution wouldn't have worked for the author of the basenote. Here is another possible solution that should work properly on all HP-UX releases (and probably on other systems as well): #include #include int getdtablesize() { #ifdef _SC_OPEN_MAX return sysconf(_SC_OPEN_MAX); #else return _NFILE; #endif } A better solution is to modify your source code to call sysconf() directly. sysconf() is part of the POSIX 1003.1 standard, so should be the most portable solution. getdtablesize() is a BSDism, so will probably only be available on BSD or BSD derived systems. Scott Holbrook / rsh@hpfcla.fc.hp.com HP-UX kernel/commands