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

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!convex!convex!tchrist
  3. From: Tom Christiansen <tchrist@convex.COM>
  4. Subject: Re: How do I tell if a file is open for writing?
  5. Originator: tchrist@pixel.convex.com
  6. Sender: usenet@news.eng.convex.com (news access account)
  7. Message-ID: <1992Aug20.132711.4783@news.eng.convex.com>
  8. Date: Thu, 20 Aug 1992 13:27:11 GMT
  9. Reply-To: tchrist@convex.COM (Tom Christiansen)
  10. References: <1992Aug20.031946.2150@athena.mit.edu>
  11. Nntp-Posting-Host: pixel.convex.com
  12. Organization: Convex Computer Corporation, Colorado Springs, CO
  13. X-Disclaimer: This message was written by a user at CONVEX Computer
  14.               Corp. The opinions expressed are those of the user and
  15.               not necessarily those of CONVEX.
  16. Lines: 31
  17.  
  18. From the keyboard of benjy@athena.mit.edu (Benjamin B Thomas):
  19. :I was wondering if there is an absolute method of determining if a
  20. :file is open for writing. I have been doing:
  21. :
  22. :ls -s foo > tmp1
  23. :sleep 5
  24. :ls -s foo > tmp2
  25. :cmp tmp1 tmp2
  26. :...
  27. :
  28. :inside of a csh script that looks for files periodically and if they
  29. :have finished growing, uses them. This would work fine except that the
  30. :files are coming in over the net, which causes problems when it hangs
  31. :and the file doesn't grow for awhile. 
  32. :
  33. :So, if anyone knows of a way to check that a file has actually been
  34. :closed by whatever was writing it, please let me know.
  35.  
  36. Portable?  No.  But for those bound and determined, you can 
  37. dive into the kernel can consult the open file table for 
  38. entries matching that dev/ino with flags indicating write access.
  39. I believe Dan Bernstein's pff program can do this for you.
  40.  
  41. Why you want to be doing this in a csh script is beyond me.
  42.  
  43. --tom
  44. -- 
  45.     Tom Christiansen      tchrist@convex.com      convex!tchrist
  46.     If you have ever seen the grim word "login:" on a screen, your mind
  47.     is now a wholly-owned subsidiary of The Death Star.
  48.                 John Woods in <14105@ksr.com> of comp.unix.bsd
  49.