I am having a forks.pm problem with a webapp that is using CGI::Application, Template Toolkit, and the mysql DBI modules.
My objective is to have several forked (could switch to threaded but trying not to) telnet sessions that go out to different routers, gather stat information, return all info and then output the info in a table(as well as save it to DB). If I use the forks module, I notice I am getting errors (on Apache) like:


1)DBI handle 0x8315140 cleared whilst still active
2)dbih_clearcom (drh 0x8315140, com 0x883e370, imp DBD::mysql::dr)
3)FLAGS 0x100215: COMSET Active Warn PrintWarn AutoCommit
4)PARENT undef
5)KIDS 0 (0 Active)
6)IMP_DATA undef

That is just for areas that deal with DB interaction. I also see errors when I attempt to open a filehandle: (Apache log shows in order)

1)cat, 2)write error, 3)broken pipe
##############################################
my $pid = open(CLI, "$ENV{HOME}/bin/cli all -D |") or die "couldn't fork: $!\n";

while(<CLI>) {
if ($_ =~ /\w+.*/) {
$output .= $_;
} else {
#do nothing
}
}
close(CLI);
###################################################
If I don't use forks.pm and switch to threads this doesn't happen, any ideas?


Thank you!


In reply to forks.pm, CGI::App,TT and DBD::mysql by perldragon80

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.