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
In reply to Safe forking by neilwatson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |