[sf-perl] How to monitor a spawned sub-process

David Fetter david at fetter.org
Wed Aug 9 17:25:26 PDT 2006

On Wed, Aug 09, 2006 at 04:25:31PM -0700, Loo, Peter # PHX wrote:
>    Hi All,
> I was wondering if there is a good way to monitor a spawned process
> within a Perl  program.  For example: I am using Perl DBI to run a
> SQL command.  However, I would like to give the SQL process some
> time to complete and at some  point  break out and quit if a set
> time has been exceeded.  Code example:

Others have hit the more general case, but for this particular one,
your DBMS should let you set the statement timeout for a given query,
so you'd do something like:

$dbh->do('SET statement_timeout=60000'); # milliseconds :)
$sth = $dbh->prepare(<<SQL);

if ($DBI::errstr) {
    # handling error here...
else {

HTH :)

David Fetter <david at fetter.org> http://fetter.org/
phone: +1 415 235 3778        AIM: dfetter666
                              Skype: davidfetter

Remember to vote!

More information about the SanFrancisco-pm mailing list