SEYMOUR@phast.phys.washington.EDU (07/02/88)
Peter Beckmann in Munster <BECKMANN@DMSWWU5P.BITNET> 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"