ziegast@eng.umd.edu (Eric W. Ziegast) (03/24/91)
Is it possible for two or more processes to share the same dbm file? If so, how could this be done safely? One way I'm thinking of doing this is create a ".lock" file when one process wants to modify the file: #Open DBM dbmopen(%ZLOG,'log',undef) || die "Can't open log database: $!\n"; # Do other commands . . . # Wait for access then lock sleep(2) while -e log.lock; # wait a while for access open(LOCK,"> log.lock") || die "Eeek! - lockfile: $!\n"; print LOCK "Owned by $$.\n"; close LOCK; # Modify some database entries (possible to delete?) . . . reset Z; unlink "log.lock"; # Go back to "Do other commands" (this process is repetetive). # When done, I'd lock and close the file, then unlock. I realize that there is flock, but I'm not sure it would do the job (for example, with NFS mounted files). Any suggestions? Is what I did above safe? Note: Using SunOS4.1, Ultrix 4.1 This is perl, version 3.0 $Header: perly.c,v 3.0.1.9 90/11/10 01:53:26 lwall Locked $ Patch level: 41 Thanks in advance. Eric Z. ziegast@eng.umd.edu