I just need a few more eyes to look at this code and help me determine just what in the world could possibly
be going wrong here. this is a CGI script, by the way.
open(DBA, "+< $datafile") or die "Could not read $datafile: $!";
seek(DBA, 0, 0);
open(TMPA, "+> $tempfile") or die "Could not open tempfile: $!";
flock(TMPA, 2) or die "ERROR: $!"; # it dies here?
seek(TMPA, 0, 0);
# more code here, etc etc ...
Of course, this is only a small piece of a MUCH larger script I've already written.
I'm opening a datafile and comparing it to some user input,
and then opening a tempfile to write any lines that should
be preserved from DBA. Then I'd rewind both files and
write from TMPA to DBA and then truncate, and close.
Anyhow, the real problem comes in when I try to flock the
temp file. I've put debugging lines in the code with
messages that say things like "I've got this far" or
whatever, after each line. And it gets all the way up
to that flock call to the TMPA filehandle just fine. But if
I let the script try to execute that line, the browser just
sits there and hangs... like it's in a loop or something.
What might be happening here? The first flock call to the DBA filehandle works just fine. I'm pulling my hair out after staring at this code for over an hour now. Please help.