Greetings,

I'm trying to write a test program for an irc bot. My plan is to create a second bot, have the two bots talk to each other, and then check the results. So, I wrote some test code to start each bot and run them toether for a brief amount of time. It seems that rather than running in parallel the bots run in sequence. What have a done wrong or is there a better way?

#!/usr/bin/env perl use strict; use warnings; use Carp; fork_bot({ bot => './cfbot.pm --debug', runtime => 60 }); fork_bot({ bot => './cfbot_tester.pm', runtime => 20 }); sub fork_bot { my ( $arg ) = @_; my $pid = fork(); if ( $pid == 0 ){ exec( $arg->{bot} ) or croak "Cannot start [$arg->{bot}] [$!]"; } else{ sleep $arg->{runtime}; kill 1, $pid or croak "Cannot kill pid [$pid]"; } return; }

Neil Watson
watson-wilson.ca


In reply to Forking two processes in parallel by neilwatson

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.