home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / shell / 3120 < prev    next >
Encoding:
Internet Message Format  |  1992-07-24  |  1.4 KB

  1. Path: sparky!uunet!sun-barr!ames!pacbell.com!network.ucsd.edu!nic!netlabs!lwall
  2. From: lwall@netlabs.com (Larry Wall)
  3. Newsgroups: comp.unix.shell
  4. Subject: Re: file locking in shell scripts
  5. Message-ID: <1992Jul24.172549.28843@netlabs.com>
  6. Date: 24 Jul 92 17:25:49 GMT
  7. References: <1992Jul23.124327.20843@cv.ruu.nl> <FRIEDMAN.92Jul24055302@nutrimat.gnu.ai.mit.edu>
  8. Sender: news@netlabs.com
  9. Organization: NetLabs, Inc.
  10. Lines: 18
  11. Nntp-Posting-Host: scalpel.netlabs.com
  12.  
  13. In article <FRIEDMAN.92Jul24055302@nutrimat.gnu.ai.mit.edu> friedman@gnu.ai.mit.edu (Noah Friedman) writes:
  14. : This is at least one way to (almost) do locking in pure shell script.  I
  15. : suspect other methods are probably more difficult, if not also presently
  16. : impossible.  However, you can write a small C program to do the atomic
  17. : exclusive file creation, returning an exit status that indicates whether it
  18. : succeeded or failed.  Then the rest can probably be done in shell script
  19. : (depending on what else you want to do, that is).
  20. :    Tom or Larry: can perl do this correctly?
  21.  
  22. I believe exclusive open is actually fairly useless in the presence of
  23. certain Network File Silesystems which shall go unnamed, but perl does
  24. give you access to either flock() or lockf() (the latter via ioctl()).
  25. For a really safe atomic operation, though, use link--I don't think
  26. anyone's found a way to botch that up yet.  But I could become wrong.
  27.  
  28. Larry Wall
  29. lwall@netlabs.com
  30.