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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |