On Thu, Nov 02, H. Peter Anvin wrote:

> [EMAIL PROTECTED] wrote:
> > 
> > Hi,
> > 
> > > > First, for compilation I needed to include <linux/limits.h> rather
> > > > than <limits.h>.
> > > > I'm running Debian `woody' and the header files distributed with Debian
> > > > might differ from your development installation.
> > >
> > > I find this surprising.  I think there's something wrong with your compiler
> > > setup.  lookup_program is just a normal piece of plain C, and shouldn't need
> > > kernel headers for anything.  What error message do you get?
> > 
> 
> The problem is the need to close all open file descriptors except
> stdin/stdout/stderr.

Yes, but for this you should not use OPEN_MAX. OPEN_MAX is constant,
while you can change the max. number of file descriptors with the
proc file interface.

Here is a patch I found in our sources:

--- modules/lookup_program.c
+++ modules/lookup_program.c    2000/11/02 18:31:58
@@ -93,6 +93,7 @@
   enum state { st_space, st_map, st_done } state;
   int quoted = 0;
   int ret;
+  int max_fd;
 
   syslog(LOG_DEBUG, MODPREFIX "looking up %s", name);
 
@@ -138,12 +139,15 @@
   FD_ZERO(&ourfds);
   FD_SET(pipefd[0],&ourfds);
   FD_SET(epipefd[0],&ourfds);
+  max_fd = pipefd[0];
+  if (max_fd < epipefd[0])
+    max_fd = epipefd[0];
 
   files_left = 2;
 
   while (files_left != 0) {
     readfds = ourfds;
-    if ( select(OPEN_MAX, &readfds, NULL, NULL, NULL) < 0 && 
+    if ( select(max_fd + 1, &readfds, NULL, NULL, NULL) < 0 && 
         errno != EINTR )
       break;
 


-- 
Thorsten Kukuk       http://www.suse.de/~kukuk/       [EMAIL PROTECTED]
SuSE GmbH            Schanzaeckerstr. 10            90443 Nuernberg
Linux is like a Vorlon.  It is incredibly powerful, gives terse,
cryptic answers and has a lot of things going on in the background.

Reply via email to