if (my $pid = fork) { l("D","$restr [$tbn] [se_id:$se->{scenario_exec_id}] forking ($pid) $se->{suite_name}:$se->{scenario_name}"); $V{scenario_exec_childs}->{$se->{scenario_exec_id}}{pid} = $pid; $V{scenario_exec_childs}->{$se->{scenario_exec_id}}{start_time} = $before_exec; # prepopulate before next cycle for state consistency, $se is referenced in the $ses array ref in main loop $se->{status} = "RUNNING"; set_scenario_exec_state($se,{ -testbed_id=>$tb_id, -pid=>$pid, -start=>"now()", status=>"RUNNING" }); sleep 2; } elsif (defined $pid) { $0 = "$restr $tbn SE:$se->{scenario_exec_id}"; l("D", "top of se fork: " . $dbh); # once and for all, I think I have figured out the forking + DBI connection handling issue! 2007-04-23, # we clone the handle, undef it, then copy over the old variable in the new process # suppress warning from clone call... I think something is broken with DBI # produces: Can't set DBI::db=HASH(0x82cf704)->{User}: unrecognised attribute or invalid value at # /volume/perl/lib/site_perl/5.8.5/i386-freebsd/DBI.pm line 648. my $saved_warn_handler = $SIG{__WARN__}; $SIG{__WARN__} = sub {}; my $child_dbh = $dbh->clone(); $SIG{__WARN__} = $saved_warn_handler; l("D", "cloned child_dbh: " . $child_dbh); $dbh->{InactiveDestroy} = 1; undef $dbh; $dbh = $child_dbh;