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