J
James
Hi,
I want to use $dbh to fetch some data from a MySQL database and then
based on that data, fork off another process to work on that data, but
I get the following error messages and then Perl crashes when running
"main.pl".
Does anyone have any ideas on how to fix this problem?
The output of the program should be:
Any help much will be much appreciated. Cheers!
=====================================
W:\libs>perl main.pl
Use of uninitialized value in print at Gen.pm line 17.
Attempt to free non-existent shared string.
Attempt to free non-existent shared string.
Attempt to free non-existent shared string during global destruction.Issuing rollback() for database handle being DESTROY'd without
explicit disconne
ct().
(in cleanup) panic: DBI active kids (-2) < 0 or > kids (0).
DBI handle cleared whilst still active.
(in cleanup) panic: DBI active kids (-3) < 0 or > kids (0).
-----------------
File: myModule.pm
-----------------
#!/perl/bin/perl
package myModule;
require Exporter;
@ISA = (Exporter);
use Gen;
use Mysql;
sub getOutput() {
my $OUTPUT = "this is the output!\n";
return $OUTPUT;
}
1
;
------------
File: Gen.pm
------------
#!/perl/bin/perl
package Gen;
require Exporter;
@ISA = (Exporter);
sub runPacket() {
my $packet = $_[1];
my $output = "";
my $isparent = 1;
my $newpid = fork();
if ($newpid==0) {
my $load = "${PACKETDIR}\:\:${packet}Lib";
$isparent = 0;
eval "require $load";
my ($cond) = eval "${packet}Lib->getOutput();";
open (OUTPUT, ">$$.tmp");
print OUTPUT $cond;
close (OUTPUT);
}
if (!($isparent)) {
exit ( 0 );
} else {
waitpid ($newpid, 0);
open (INPUT, "$newpid.tmp");
while (<INPUT>) { $output .= $_; }
close (INPUT);
unlink "$newpid.tmp";
}
return $output;
}
1
;
-------------
File: main.pl
-------------
#!/perl/bin/perl -w
require Gen;
use Mysql;
my $dbh = Mysql->connect ("localhost", "testdb", "", "");
$output = Gen->runPacket ("myModule");
print "> $output\n";
I want to use $dbh to fetch some data from a MySQL database and then
based on that data, fork off another process to work on that data, but
I get the following error messages and then Perl crashes when running
"main.pl".
Does anyone have any ideas on how to fix this problem?
The output of the program should be:
this is the output!
Any help much will be much appreciated. Cheers!
=====================================
W:\libs>perl main.pl
Use of uninitialized value in print at Gen.pm line 17.
Attempt to free non-existent shared string.
Attempt to free non-existent shared string.
Attempt to free non-existent shared string during global destruction.Issuing rollback() for database handle being DESTROY'd without
explicit disconne
ct().
(in cleanup) panic: DBI active kids (-2) < 0 or > kids (0).
DBI handle cleared whilst still active.
(in cleanup) panic: DBI active kids (-3) < 0 or > kids (0).
-----------------
File: myModule.pm
-----------------
#!/perl/bin/perl
package myModule;
require Exporter;
@ISA = (Exporter);
use Gen;
use Mysql;
sub getOutput() {
my $OUTPUT = "this is the output!\n";
return $OUTPUT;
}
1
;
------------
File: Gen.pm
------------
#!/perl/bin/perl
package Gen;
require Exporter;
@ISA = (Exporter);
sub runPacket() {
my $packet = $_[1];
my $output = "";
my $isparent = 1;
my $newpid = fork();
if ($newpid==0) {
my $load = "${PACKETDIR}\:\:${packet}Lib";
$isparent = 0;
eval "require $load";
my ($cond) = eval "${packet}Lib->getOutput();";
open (OUTPUT, ">$$.tmp");
print OUTPUT $cond;
close (OUTPUT);
}
if (!($isparent)) {
exit ( 0 );
} else {
waitpid ($newpid, 0);
open (INPUT, "$newpid.tmp");
while (<INPUT>) { $output .= $_; }
close (INPUT);
unlink "$newpid.tmp";
}
return $output;
}
1
;
-------------
File: main.pl
-------------
#!/perl/bin/perl -w
require Gen;
use Mysql;
my $dbh = Mysql->connect ("localhost", "testdb", "", "");
$output = Gen->runPacket ("myModule");
print "> $output\n";