[net.sources.games] problems with galaxy/robots/others on Sys V Rel 2

rcj@burl.UUCP (Curtis Jackson) (06/11/85)

The problems mentioned compiling galaxy, robots, and others are
due to the use of the flock() utility of BSD, which Sys V does
not have.  flock() is a general-purpose advisory lock routine
for files (i.e., we want to make sure that two players aren't
writing the score file at the exact same time).

I am too swamped at the moment to write a public-domain version
of flock(), and from the hell I caught last time I posted something
MUCH more trivial than flock()  [dup2()] that I had written myself,
I don't think I'd be able to do so anyway.

If anyone has/is_willing_to_write a public-domain flock(), I for
one would be quite interested in it; otherwise I'll have to write
one at a later date and my colleages will not be able to play
these goodies until then.

Thanks to anyone with pointers to public domain flock(),
-- 

The MAD Programmer -- 919-228-3313 (Cornet 291)
alias: Curtis Jackson	...![ ihnp4 ulysses cbosgd mgnetp ]!burl!rcj
			...![ ihnp4 cbosgd akgua masscomp ]!clyde!rcj

cwd@cuae2.UUCP (Chris Donahue) (06/17/85)

> The problems mentioned compiling galaxy, robots, and others are
> due to the use of the flock() utility of BSD, which Sys V does
> not have.  flock() is a general-purpose advisory lock routine
> for files (i.e., we want to make sure that two players aren't
> writing the score file at the exact same time).
> 
> I am too swamped at the moment to write a public-domain version
> of flock(), and from the hell I caught last time I posted something
> MUCH more trivial than flock()  [dup2()] that I had written myself,
> I don't think I'd be able to do so anyway.

UNIX System V Rel. 2 does support file locking through the fcntl system
call. Use the GETLK, SETLK, SETWLK commands with fcntl as a substitute
for flock. A replacement for flock would be a 2-5 line subroutine
at the most.

Chris Donahue
AT&T Info. Sys.
Application Engineering

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (06/18/85)

> The problems mentioned compiling galaxy, robots, and others are
> due to the use of the flock() utility of BSD, which Sys V does
> not have.

Check out lockf() and the more general locking features of fcntl().
These were added in Rel. 2 Ver. 2.

guy@sun.uucp (Guy Harris) (06/18/85)

> > The problems mentioned compiling galaxy, robots, and others are
> > due to the use of the flock() utility of BSD, which Sys V does
> > not have.  flock() is a general-purpose advisory lock routine...

> UNIX System V Rel. 2 does support file locking through the fcntl system
> call.

UNIX S5R2V2 (for the VAX, anyway) supports file locking, but S5R2V1 doesn't.
This caused a problem when a "System V compatible" version of one of the
aforementioned games didn't build on a System V system.

Until such time as every UNIX system out there supports file locking, you
might want to consider the "old reliable" link mechanism.  Each file to be
locked has a file associated with it (which can be the file itself).  To
lock the file, make a link to the associated file (which has a well-known
name) with another well-known name.  If the link already exists (i.e., the
file is locked), the link will fail.  "unlink" unlocks the file.  Crude, but
effective, and it works on every UNIX out there.

	Guy Harris