home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / question / 10237 < prev    next >
Encoding:
Text File  |  1992-08-20  |  1.4 KB  |  42 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!stanford.edu!ames!data.nas.nasa.gov!ace!jns
  3. From: jns@ace.nas.nasa.gov (John N. Stewart)
  4. Subject: Re: How do I tell if a file is open for writing?
  5. References: <1992Aug20.031946.2150@athena.mit.edu> <1992Aug20.132711.4783@news.eng.convex.com>
  6. Sender: news@nas.nasa.gov (News Administrator)
  7. Organization: NAS, NASA Ames Research Center, Moffett Field, CA
  8. Date: Thu, 20 Aug 92 23:46:43 GMT
  9. Message-ID: <1992Aug20.234643.27829@nas.nasa.gov>
  10. Lines: 30
  11.  
  12. In article <1992Aug20.132711.4783@news.eng.convex.com> tchrist@convex.COM (Tom Christiansen) writes:
  13. >From the keyboard of benjy@athena.mit.edu (Benjamin B Thomas):
  14. >:I was wondering if there is an absolute method of determining if a
  15. >:file is open for writing. I have been doing:
  16. >:
  17. >:ls -s foo > tmp1
  18. >:sleep 5
  19. >:ls -s foo > tmp2
  20. >:cmp tmp1 tmp2
  21.  
  22. [-stuff deleted-]
  23.  
  24. >Portable?  No.  But for those bound and determined, you can 
  25. >dive into the kernel can consult the open file table for 
  26. >entries matching that dev/ino with flags indicating write access.
  27. >I believe Dan Bernstein's pff program can do this for you.
  28.  
  29.  
  30.  
  31. I would use the time of last access on a stat command, if you are
  32. trying to do this in CSH you've got some problems. DO IT IN PERL!
  33.  
  34. My $0.02 worth -- and since it is as difficult as Tom C. says, and he
  35. is a Perly guy, I hope he agrees :)
  36.  
  37. --
  38. John Stewart (Ace)
  39. CSS/DSS
  40. NASA Ames Research Center
  41. (415) 604-4345
  42.