Thursday, May 1, 2008

Determine the number of file descriptors

# include

# include

# include “ourhdr.h”

# ifdef OPEN_MAX

static int openmax = 0;

# else

static int openmax =0;

# endif

# define OPEN_MAX_GUESS 256

int

open_max(void)

{

if(openmax = = 0)

{

errno=0;

if( (openmax=sysconf(_SC_OPEN_MAX) ) <>

{

if(errno = = 0)

openmax = OPEN_MAX_GUESS;

else

err_sys(“sysconf error for SC_OPEN_MAX”);

}

}

return (openmax);

}

No comments: