-----Original Message----- >From: Chas Owens <[EMAIL PROTECTED]> >In his case there is not a portability issue. What is not portable is >using the parent's handle inside the child, but he is opening a new >handle inside the child. The problem was the auto-close behavior >which is made a non-problem by the flag. You should never expect to >be able to use a database handle from one process inside another; it >may be possible, but you should not be surprised when it breaks.
Let me also give a simple conclusion, 1) Using InactiveDestroy to disable auto-close is the correct way.Where the dbh object go away first,then put the InactiveDestroy there.For example,this could work, use MyDB; # a simple db class encapsulated from DBI my $db = MyDB->new; my $pid = fork; unless ($pid) { # in child $db->{dbh}->{InactiveDestroy} = 1; # in child the dbh object would go away first sleep 3; exit 0; } else { # in parent while(1) { my ($re) = $db->get_line("select 1"); print $re,"\n"; sleep 1; } } __END__ But this couldn't work, use MyDB; # a simple db class encapsulated from DBI my $db = MyDB->new; my $pid = fork; unless ($pid) { # in child sleep 3; exit 0; } else { # in parent $db->{dbh}->{InactiveDestroy} = 1; # not useful here,dbh would break due to child exiting while(1) { my ($re) = $db->get_line("select 1"); print $re,"\n"; sleep 1; } } __END__ 2) Not using InactiveDestroy,but re-creating a dbh object in child (the process go away first),is not useful.The dbh object in parent (the process which keep alive) would still break.Case is shown below, use MyDB; # a simple db class encapsulated from DBI my $db = MyDB->new; my $pid = fork; unless ($pid) { # in child my $db = MyDB->new; # re-create a dbh object sleep 3; exit 0; } else { # in parent while(1) { my ($re) = $db->get_line("select 1"); print $re,"\n"; sleep 1; } } __END__ -- mailto:[EMAIL PROTECTED] http://home.arcor.de/jeffpang/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/