my $childPid = fork(); if ($childPid) { sleep 2; ## then open the database ## do stuff kill 'HUP', $childPid; } else { exec("ssh $user\@$host -L 3306:$host:3306 -N"); }