From: CSBVAX::MRGATE!info-vax-RELAY@KL.SRI.COM@SMTP 8-JUL-1988 19:34 To: ARISIA::EVERHART Subj: RE: open file count from a program Received: from CUNYVM.CUNY.EDU by KL.SRI.COM with TCP; Fri, 1 Jul 88 13:53:08 PDT Received: from phast.phys.washington.edu by CUNYVM.CUNY.EDU (IBM VM SMTP R1.1) with BSMTP id 1557; Fri, 01 Jul 88 16:50:51 EDT Date: Fri, 1 Jul 88 13:51 PST From: SEYMOUR%phast.phys.washington.edu@CUNYVM.CUNY.EDU Subject: RE: open file count from a program To: info-vax@kl.sri.com X-VMS-To: IN%"info-vax@kl.sri.com" Peter Beckmann in Munster asked: >does anyone know a possiblity to get information about the number of >opened files from within a program. the answer is: CALL SYS$GETJPIW asking for two pieces of information. (system services manual, around page sys-213) you want jpi$_FILLM (your process's open file limit) and jpi$_FILCNT (how many remain of that limit) subtract the second from the first, and you've got how many are open (including the program's .exe itself, etc. -- thus an overhead of 1) messy fortran sample: (no structures, just good ol' equivalences) -------------------------------cut here------------------------------ implicit integer*4 (a-z) integer*2 itemword(18) integer*4 itemlist(9) equivalence (itemword,itemlist) integer*4 filelimit, filesleft, filesopen integer*4 lenlimit, lenleft include '($jpidef)' itemword(1)=4 ! authorized length of result itemword(2)=jpi$_fillm ! open file limit (from UAF) itemlist(2)=%loc(filelimit) ! where to put the answer itemlist(3)=%loc(lenlimit) ! how many bytes came back itemword(7)=4 itemword(8)=jpi$_filcnt itemlist(5)=%loc(filesleft) itemlist(6)=%loc(lenleft) itemlist(7)=0 ! end of request list c we call the WAIT version of the service c defaulting everything call sys$getjpiw(,,,itemlist,,,) filesopen=filelimit-filesleft type *,'quota:',filelimit,', remaining:',filesleft type *,'there are',filesopen,' files open' end -----------------------cut here----------------------------------------- (i get "2" when i run it from a command file, "1" from my terminal) -- see also the little book "guide to programming on VAX/VMS (Fortran edition) page 3-33. there's also a lexical function (f$getjpi) for DCL usage. -- dick seymour seymour@uwaphast "messy (but tested) code for all to see"