in reply to Re: Perl script crashing at lockfile ?
in thread Perl script crashing at lockfile ?
I didn't write it, and I don't know Perl very well at all.
>>Why not just do it native say like
sysopen($fh, "$dir/$name", O_CREAT | O_EXCL | O_RDWR, 0600);
Thanks for supplying the code. I don't know why the person wanted to lock the file. Here is a bigger snippet of what is happening, down to the unlink, which I think is like the "unlock" ??
system ("lockfile -2 -r 5 $base_dir/.lock") == 0 or diehtml("Lock error: ", $? >> 8, "\n"); # TODO stop stderr of system # create unique suffix if (-f "$base_dir/$seq_file") { open(SEQ, "+<$base_dir/$seq_file") or diehtml("Error opening seq file: $!\n"); $seq = ; seek SEQ, 0, 0; } else { open(SEQ, ">$base_dir/$seq_file") or diehtml("Error creating seq file: $!\n"); $seq = 0; } $outfile .= sprintf "%7.7d", $seq; $ordernumber = $seq; #store this order no. before 'next' is cal +c. print SEQ ++$seq; close SEQ or warn "Something wrong closing seq: $!\n"; unlink "$base_dir/.lock" or diehtml("Unlock error: $!\n"); open(ORDERFILE, ">$outfile") or diehtml("Can't open order records: $!\n"); print ORDERFILE @_; close ORDERFILE or warn "Something fishy with closing the order: $ +!\n"; }
The file SEQ, is just a line line ASCII file with the next order number in it.
Peter
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Perl script crashing at lockfile ?
by tachyon (Chancellor) on Oct 01, 2003 at 12:44 UTC | |
by peterr (Scribe) on Oct 02, 2003 at 02:13 UTC | |
by tachyon (Chancellor) on Oct 02, 2003 at 02:28 UTC | |
by peterr (Scribe) on Oct 02, 2003 at 04:29 UTC | |
|
Re: Re: Re: Perl script crashing at lockfile ?
by peterr (Scribe) on Oct 02, 2003 at 02:00 UTC |