Libevent error 'Bad File Descriptor'

Brad Fitzpatrick brad@danga.com
Wed, 22 Oct 2003 15:07:26 -0700 (PDT)


Sara, just move the whole section:

   if (daemonize) { ... }

Up above:

   /* initialize other stuff */
    item_init();

So it's like:

  if (daemonize) {
        int res;
        res = daemon(0, settings.verbose);
        if (res == -1) {
            fprintf(stderr, "failed to daemon() in order to daemonize\n");
            return 1;
        }
    }

    /* initialize other stuff */
    ...

Then re-make and it'll daemonize.

I'll make a new release shortly, unless Avva objects.

- Brad


On Wed, 22 Oct 2003, Sara Sioux wrote:

> Thanks for the prompt responses!  Sorry if my questions are a little
> low-brow, I'm not so great at system administration yet.  :)
>
> What are the drawbacks to running memcached in the background, instead
> of as a daemon?
>
> Sara
>
> -----Original Message-----
> From: Brion Vibber [mailto:brion@pobox.com]
> Sent: Wednesday, October 22, 2003 2:53 PM
> To: Sara Sioux; memcached@lists.danga.com
> Subject: Re: Libevent error 'Bad File Descriptor'
>
>
> On Wednesday, Oct 22, 2003, at 14:37 US/Pacific, Sara Sioux wrote:
> > memcached -vv -d -m 512 -l 10.0.0.100 -p 1337
> >
> > It returns immediately with:
> >
> > <3 server listening
> > memcached: kevent: Bad file descriptor
> [snip]
> > I'm attempting to install this on a FreeBSD 5.0-RELEASE-p4 system. Any
>
> > help and suggestions would be HUGELY appreciated.
>
> This seems to be related to how the open file descriptors get treated
> by the fork to a background process. I posted a workaround which seems
> to work on FreeBSD 5.1-RELEASE yesterday, by forking before doing
> anything substantive:
> http://lists.danga.com/pipermail/memcached/2003-October/000304.html
>
> Alternatively, you can just run it in the background without the -d
> option and it should work fine.
>
> -- brion vibber (brion @ pobox.com)
>
>