goofball
07-25-2003, 12:37 PM
I'm using flock in a Perl script when overwriting a database file. It works fine, and evidently prevents another process from overwriting the same file at the same time (as long as this other script is also using flock), but I need to know if it also prevents read access.
The database is composed of .pl files that are required by the database scripts all the time, so I want to know if using flock on a file would prevent that file from being read or required from another process. ??
Part of the script is below so you can see what I'm doing:
use Fcntl ':flock';
sub lock {
flock($_[0],LOCK_EX);
seek($_[0], 0, 2);
}
open(FILEHANDLE, ">../log_file.pl");
&lock('FILEHANDLE');
print FILEHANDLE "blah blah blah\n";
flock(FILEHANDLE,LOCK_UN);
close(FILEHANDLE);
Thanks!
The database is composed of .pl files that are required by the database scripts all the time, so I want to know if using flock on a file would prevent that file from being read or required from another process. ??
Part of the script is below so you can see what I'm doing:
use Fcntl ':flock';
sub lock {
flock($_[0],LOCK_EX);
seek($_[0], 0, 2);
}
open(FILEHANDLE, ">../log_file.pl");
&lock('FILEHANDLE');
print FILEHANDLE "blah blah blah\n";
flock(FILEHANDLE,LOCK_UN);
close(FILEHANDLE);
Thanks!