[Sussex] the who/what/why/when of processes ( proc-i ? ;)

Steve Dobson SDobson at manh.com
Thu Sep 5 14:13:00 UTC 2002


Dunk

> From: dunk fordyce

I have also just noticed <sfx: egg on face> that this is a SLUG
post not an INSIDE post.

> its actually a irc bot that sits there and listens and 
> responds to commands.

> i want to be able to start a new process for different rooms 
> and also for things like searching the web ( i dont want the 
> bot to stop responding while its searching ).

I don't know IRC or its protocol but I do see a problem here.
When you fork() the child shares the file descriptors with the
parent.  This is great as you want your bots to keep talking to
the same IRC server, yes.

Now it depend upon IRC protocol (TCP/IP or UDP/IP protocol), and
if different connections/sockets (file descriptors are the handles
to them) are being used.

Lets suppose that each room has its own connection/socket/file desc.
  If you're in two rooms then your client while be select(2)ing on
  both fds because it has no way of knowing which will receive next.
  If you fork() a new child for each room how are you going to know
  which fd is the socket for the room that bot is monitoring?

  If only one connection/socket/fd is the link to the server then if
  both your IRC client and the bot both select(2) on that fd only ONE
  while get the message.  Who knows, the kernel will decide at run-
  time.  But I guarantee that when it is a message you want the bot
  to handle it will be your client that receives and vice versa.

Writing to the server is almost as bad.  Both will work but the
kernal may mix the data streams.  There has to be a protocol between
the processes as who as the "right" to write to the server.  If this
is a stock IRC client then I'm guessing that it doesn't support such
a protocol.

> does that make more sense now?
Yes.  Do my responses make sense to you.




More information about the Sussex mailing list