Libevent error 'Bad File Descriptor'

Brion Vibber brion@pobox.com
Wed, 22 Oct 2003 15:36:16 -0700


On Wednesday, Oct 22, 2003, at 15:26 US/Pacific, Anatoly Vorobey wrote:
> I don't object - just frustrated because I don't understand why this
> is happening and why moving the code solves it. Did you figure it out?

Hmm... from the man page for kqueue(2):

      The kqueue() system call creates a new kernel event queue and 
returns a
      descriptor.  The queue is not inherited by a child created with 
fork(2).
      However, if rfork(2) is called without the RFFDG flag, then the 
descrip-
      tor table is shared, which will allow sharing of the kqueue 
between two
      processes.

daemon(3) works by fork()ing off a child process and exiting the 
parent, so we lose the queue in the child if we set it up in the parent 
process.

-- brion vibber (brion @ pobox.com)