How can I share a database connection in a forked process in Perl?
I've made the following programs in Perl before:
my $db = DBconnection with DB2
if ($pid = fork()) {
#parent
} else {
#child
$db->execute("SELECT ****");
exit;
}
wait();
$db->execute("SELECT ****");
I thought that he was waiting for the end of the child process to want to do this, and will manage it for the pro-process database.
Also, the DB is not connected to the error content.
What's wrong?
0
a source to share
2 answers
There are many things you must do to allow a child process to use the parent DBI descriptor. See this article on Perl Monks about DBI, fork and clone .
+5
a source to share