Hi!

I have a Perl script that opens a number of DBM files. It also starts
other programs via calls to "system". I recently found out that the
"handles" to the DBM-files seem to be inherited by the newly started
process. I would like to avoid this. Does anybody know how to do this?

To demonstrate my "problem" I wrote the little script given below. It
uses "notepad" as an example of an external program that will inherit
the filehandles. To run the example I did:

  c:\> perl start-notepad.pl
          -----> Press Ctrl-C to terminate the Perl script.
  Terminating on signal SIGINT(2)
  c:\>
  c:\> rm -f foo-dbm.dir foo-dbm.pag
  rm: cannot unlink entry "foo-dbm.dir": The process cannot access the
file because it is being used by another process.
  rm: cannot unlink entry "foo-dbm.pag": The process cannot access the
file because it is being used by another process.
  c:\>

After terminating "notepad" I can remove the DBM files without problems.

/Johan Holmberg

#----------------------
# start-notepad.pl

use Fcntl;
use SDBM_File;
use strict;

my %h;
my $status_file = "foo-dbm";

tie(%h, "SDBM_File", $status_file, O_RDWR|O_CREAT,0666)
    or die "Error: Can't open DBM file '$status_file': $!\n";

system "notepad foo.txt";
#----------------------
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to