neilwatson has asked for the wisdom of the Perl Monks concerning the following question:
Greetings fellow avout,
I'm working on an IRC bot. Currently the bot listens for messages on the channel. I want add a feature that will read an external feed (e.g. github api) and send messages to the channel based on the return. My thought was to fork a separate process for that. This is a forking POC prototype. Am I on the right track and what kind of fork safety features should I include?
#!/usr/bin/perl use strict; use warnings; use feature 'say'; if ( fork ) { while ( 1 ) { say "Listening for irc public message"; my $msg = <STDIN>; chomp $msg; say "Your message: $msg"; } } else { while ( 1 ) { sleep 15; say 'Walking up to read a feed and send a message'; } }
Neil Watson
watson-wilson.ca
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Safe forking
by Anonymous Monk on Jun 24, 2015 at 13:35 UTC | |
|
Re: Safe forking
by Anonymous Monk on Jun 24, 2015 at 15:59 UTC |