Solved

DB_File - flock

Posted on 1998-11-01
5
185 Views
Last Modified: 2010-03-04
This is an attempt to flock a database, a modified version of a snippet of code from the PERL docs at http://www.perl.com/CPAN-local/doc/manual/html/lib/DB_File.html#HINTS_AND_TIPS.

# begin code

use DB_File;
use Fcntl;
# ...
$database = "/home/test/temp.dbm";
$db = tie(%hash, DB_File, $database, O_RDRW|O_CREAT, 0777) || die "Could not tie database!";
$fd = $db->fd;
open(DB_FH, "+<&=$fd") || die "dup ($!)";  # dies here
flock (DB_FH, 1);
# ...
flock (DB_FH, 8);
undef $db;
untie(%hash);
close(DB_FH);

# end code

The error arises from the line: open(DB_FH, "+<&=$fd").  Now, I understand  the concept behind "+<&$fd", but why would this open fail when the tie() did not?  The script terminates without setting $!.

If anyone can answer this I would really appreciate it.  Pardon any typos, its been a long weekend.

Daniel Crowe
Evernight Design
0
Comment
Question by:Evernight
  • 4
5 Comments
 

Author Comment

by:Evernight
ID: 1205859
Adjusted points to 150
0
 

Author Comment

by:Evernight
ID: 1205860
I don't think I've ever spent so much time trying to figure out what the leters "dup" stand for. ;p
0
 

Author Comment

by:Evernight
ID: 1205861
Anyone have any idea?  Even a hint or suggestion?  Please.
0
 

Author Comment

by:Evernight
ID: 1205862
Adjusted points to 209
0
 

Accepted Solution

by:
Igloo earned 200 total points
ID: 1205863
Try RDWR intead of RDRW ;-)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question