Solved

DB_File - flock

Posted on 1998-11-01
5
183 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
Comment Utility
Adjusted points to 150
0
 

Author Comment

by:Evernight
Comment Utility
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
Comment Utility
Anyone have any idea?  Even a hint or suggestion?  Please.
0
 

Author Comment

by:Evernight
Comment Utility
Adjusted points to 209
0
 

Accepted Solution

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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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 …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now