[comp.unix.questions] Locking from shell scripts

lee@sq.sq.com (Liam R. E. Quin) (06/08/90)

In article <779@mwtech.UUCP> martin@mwtech.UUCP (Martin Weitzel) writes:
>In article <475@van-bc.wimsey.bc.ca> sl@van-bc.wimsey.bc.ca (Stuart Lynne) writes:
>[about locking from interface programs of the SysV spool system]
>Locking with FIFOs [...]
> It is essential that the daemon keeps
>the FIFO open for read and write, so that the character in it
>is never discarded! All in all it's a bit tricky to get this
>started, as you can open a FIFO from the shell only for read OR
>for write

You could investigate the <> syntax in the shell, which opens an
existing file in read-write mode.  This was documented briefly in
System III as I recall, and also in a Unix quick-reference card of
about 1983 or so, but I've not seen it since.

Most shells actually use read/write in any case, although relying
on this might be a bad idea.


Script started on Thu Jun  7 20:49:38 1990
sqarc!lee> ls -l <> boy
boy: cannot open
sqarc!lee> date > boy
sqarc!lee> cat <> boy
Thu Jun  7 20:50:12 EDT 1990
sqarc!lee> cat boy
Thu Jun  7 20:50:12 EDT 1990
sqarc!lee> date 1<> boy
sqarc!lee> cat boy
Thu Jun  7 20:50:41 EDT 1990
sqarc!lee>

script done on Thu Jun  7 20:50:52 1990

Lee

-- 
Liam R. E. Quin,  lee@sq.com, {utai,utzoo}!sq!lee,  SoftQuad Inc., Toronto
``It's just an idea, and admittedly a half-baked, unlikely one.  Still,
  picking apart ideas is what the net is all about.'' [David Brin, _Earth_]