> I added that and also added a close to the client side, but I still
> get this error:
>
> server:
> ./socketbug.rb:6:in `wait': No child processes (Errno::ECHILD)
>         from ./socketbug.rb:6
>         from ./socketbug.rb:5:in `call'
>         from ./socketbug.rb:11
>
> It seems to happen randomly, but maybe every 500 or so requests?
> Any idea what causes it?

If you do this:

trap("CLD") do
  Process.wait
end

50.times do
  if !fork() then
    exit
  end
end

sleep 10

you should see the same result.  According to the wait(2) man page, wait
can return ECHILD if there are no unwaited-for child processes.  I'm not
positive, but what I think is happening is:

1) A child exits and becomes a zombie.  The parent gets a SIGCHLD.
2) A child exits and becomes a zombie.  The parent gets a SIGCHLD.
3) The parent's signal handler is called.  The parent waits on the two
children to completely exit.
4) The parent's signal handler is called.  Because both children have
already exited, there are no processes to wait on.  Thus wait returns
ECHILD, and Ruby re-throws it as an exception.

As for the ENOBUFS problem, perhaps you really are running out of buffer
space?

Paul