#!/usr/bin/perl -w use DBI; use strict; my $dbh = DBI->connect("DBI:mysql:test", "user", "pwd", { RaiseError => 1 }) or die "can't connect\n"; my $query = qq{select user(), NOW()}; my $sth = $dbh->prepare($query); my $pid ; FORK: { if ($pid = fork) { print "I am the parent (PID: $$) and $pid is my child \n"; print_result($sth); } elsif (defined $pid) { print "I am the child ($$)\n"; $dbh->{InactiveDestroy} = 1; # line 23 print_result($sth); } else { die "Can't fork: $!\n"; } } sub print_result { my $st = shift; return unless $st; print "process id: $$\n"; $st->execute() or die "can't execute (PID $$), ($DBI::errstr)\n"; while (my $row = $st->fetchrow_arrayref()) { print ">> @$row\n"; } } __END__ I am the parent (PID: 2812) and 2813 is my child I am the child (2813) process id: 2813 >> gmax@localhost 2003-11-30 18:06:20 process id: 2812 >> gmax@localhost 2003-11-30 18:06:20