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

[MacPerl] file locking



I am working on DBD::CSV right now.  I built two required modules,
SQL::Statement and Text::CSV_XS, and fixing portability problems in
DBD::CSV itself (which requires DBI, which I have also built).

Anyway, there is a flock() done on the CSV file.  At first I just did an if
($^O ne 'MacOS') around the flocks.  But now I am thinking something like
this might be better:

  if ($^O eq 'MacOS') {
    chmod(0444, $file);
    eval("END {chmod 0666, '$file'}");
  } else {
    do_flock_stuff;
  }

I think that should lock the file, and then unlock it open exiting the
program, even if it exits prematurely (unless MacPerl itself dies).

Any thoughts?

There is a thought that perhaps flock() itself can be mapped to Mac OS file
locking, and MacPerl can keep track of what to unlock, maybe by keeping
track of all flocks and knowing what MacPerl locked and what it needs to
unlock.  But that is another thing for another time.

Thanks,

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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