mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miquel van Smoorenburg <miquels@cistron.nl>
To: linux-kernel@vger.kernel.org
Subject: Re: fd_setsize
Date: Fri, 14 Dec 2001 09:53:54 +0000 (UTC)	[thread overview]
Message-ID: <9vci7i$8eh$2@ncc1701.cistron.net> (raw)
In-Reply-To: <OFB046FAEF.D6FAB48A-ON86256B22.00075ECB@3com.com>

In article <OFB046FAEF.D6FAB48A-ON86256B22.00075ECB@3com.com>,
 <Hui_Ning@3com.com> wrote:
>I am using 2.4 kernel. How can I increase the fd_setsize so that I can use
>select to check more than 1024 file descriptors?

That's more a glibc question. On many systems, you can set
FD_SETSIZE before including <sys/select.h> and the libs will
use that FD_SETSIZE from that point on.

With glibc, you can't do that. Well that's not entirely true, the
following works but is not portable and an unbelievable hack.

BTW, why not use poll() - it has no fd_set imposed limit.

BTW2 don't forget to increase the ulimit filedescriptor max,
and perhaps /proc/sys/fs/{file-max,inode-max}

/*
 * Cannot increase FD_SETSIZE on Linux, but we can increase __FD_SETSIZE
 * with glibc 2.2 (or later? remains to be seen). We do this by including
 * bits/types.h which defines __FD_SETSIZE first, then we redefine
 * __FD_SETSIZE. Ofcourse a user program may NEVER include bits/whatever.h
 * directly, so this is a dirty hack!
 */
#include <features.h>
#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
#    include <bits/types.h>
#    undef __FD_SETSIZE
#    define __FD_SETSIZE 8192
#endif

Mike.
-- 
Deadlock, n.:
        Deceased rastaman.


      reply	other threads:[~2001-12-14  9:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-14  1:22 fd_setsize Hui_Ning
2001-12-14  9:53 ` Miquel van Smoorenburg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='9vci7i$8eh$2@ncc1701.cistron.net' \
    --to=miquels@cistron.nl \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®