in reply to Re: DBI and fork() on Win32
in thread DBI and fork() on Win32

Thanks, I think I understand, it's not the handle but the driver that causes problems?

Unfortunately, system() doesn't help because I need each job to be executed in paralell and I don't want to sit around and wait for each one of them.

I have tried rewriting &child() like this:

sub child { my $job = shift; exec("perl", "child-script", $job); exit; # Just in case }
...but DBI still crashes with the same message.

Replies are listed 'Best First'.
Re^3: DBI and fork() on Win32
by Corion (Patriarch) on Feb 10, 2009 at 14:53 UTC

    exec is not the solution. I didn't show a plain system() call but system(1, ...), which is mentioned in perlport, and which executes the program separately from the main program. This is mostly the same as system("start $cmd"); except that the latter involves the shell.

      I'm ready to just give up... Got rid of the fork() and replaced with
      system(1, "perl", "child-script", $job);
      This crashes too, even when 'child-script' contains just two lines:
      print "hello world\n"; exit;

        You need to be a bit more precise because the following Works On My Machine:

        #!perl -w use strict; use DBI; my $dsn = 'dbi:SQLite:dbname=tmp.sqlite'; while (1) { my $dbh = DBI->connect($dsn,undef,undef,{RaiseError => 1}); # Parent + connecting # .. get a job list .. my @jobs = qw(Corion FloydATC FloydATD); $dbh->disconnect(); # <-- NB! foreach my $job (@jobs) { my @cmd = ($^X, '-le', q{"print 'Processing ', join '_', @ARGV"}, +$job); system(1, @cmd); } sleep 1; } print "Done.";

        Of course, I'm not really doing anything with the DBI handle, but maybe you can try my version and then work your way up to your version.