It seems you want to use the same connection from both the parent process and the child process.

If so, you should at least make sure you set $^F to whatever is the correct value for your program, otherwise the exec()d child will not receive the database handle (since close-on-exec will - probably - be set) update: this may have no effect if the database socket is actually open()ed by C library code instead of perl code.

Also, the child program should be written to support the notion of an inherited database handle - many database-using programs aren't - they just open their own connection.

The integer you're looking for my be the fileno() of the database connection socket, but don't ask me how to get at that portably (or even non-portably).

Or maybe I'm completely misinterpreting your question. It happens.

update 2: from the DBI docs, it appears that child processes may inherit the database handle across a fork(), but 1) it says nothing about exec() and 2) it notes that some databases don't support doing that.


In reply to Re: DB connection after fork, exec by Joost
in thread DB connection after fork, exec by bkchapin

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.