I'm running across an odd situation in a web application in mod_perl using DBD::Pg and calling system().

From packet traces on loopback, I've determined that STDOUT from my calls to system() is getting mapped to the Pg client socket and is sent to the postgres server. This makes postgresql freak and drop all of my database connections. So, if I have a code path like this:

sub foo { $dbh->begin(); my $bar = select_some_stuff_from_pgsql($dbh); my $ret = system("echo This gets written to stdout"); insert_some_stuff_into_pgsql($dbh); $dbh->commit(); }

my call to system totall hoses the transaction. So my question is... Has anyone seen this behavior before? How do I stop mod_perl from mapping stdout to my pgsql control socket? Is there some way to map stdout to something different *only* in system calls in mod_perl?

For a bit of clarification on what I'm talking about.. here's a snippet from tethereal on loopback:

26 3.393679 127.0.0.1 -> 127.0.0.1 POSTGRESQL Request This is + written to stdout... llamas 27 3.394063 127.0.0.1 -> 127.0.0.1 POSTGRESQL Response USFATA +L C08P01 Minvalid frontend message type 84 Fpostgres.c L366 RSocketBa +ckend

Thanks for any help anyone can provide.


In reply to mod_perl + system + stdout + DBD::Pg by bmdhacks

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.