[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] MacPerl & Databases



On Sun, 3 Jan 1999 09:46:51 -0500, Chris Nandor wrote:

>>It works on PC too.
>>
>>In fact, it should work on any platform with implicit locking when
>>opening a file for output.
>
>Yes, well, the point is that it is not portable to _all_ other platforms.

You could distinguish two major groups of OS'es.

 A) including Mac, DOS, Win95 (but I'm not sure about NT): "personal"
OS. This allows only one entry to a file open for output at any time.
This means that the OS supports implicit locking.

 B) Unix and similar: multi-user OS. this one does allow several
programs to write to the same file at the same time. No implicit
locking. So, you need an explicit flock here, but ONLY here.

Some ports, like the OS/2 port (that runs on DOS), simply ignore
flock(). Others, such as MacPerl and the DOS GNU port, give an error on
flock(). I think the OS/2 behaviour is more sensible. In that case, the
next code would ALWAYS work:

	open(FILE,"+<somefile");
	flock FILE,LOCK_EX; 	#see Fcntl.pm
	.... access the file exclusively
	close FILE; # release lock

As it is now, you need to check $^O to see if your platform
supports/needs flock. Very messy.

I would prefer it if at least there would be some flag available to the
Perl programmer to see which case you're in.

	Bart.

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch