bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix weird _SC_OPEN_MAX usage


From: Jonas 'Sortie' Termansen
Subject: Fix weird _SC_OPEN_MAX usage
Date: Wed, 06 Aug 2014 11:15:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

Hi,

The files

lib/spawn_faction_addopen.c
lib/spawn_faction_addclose.c
lib/spawn_faction_adddup2.c

contains this unusual pattern:

#if !_LIBC
# define __sysconf(open_max) getdtablesize ()
#endif
...
int maxfd = __sysconf (_SC_OPEN_MAX);

This is non-portable to new systems that doesn't have the non-standard
getdtablesize() function, but implements the standard sysconf value. The
desirable pattern would be to just use the real standard sysconf call
directly:

int maxfd = sysconf (_SC_OPEN_MAX);

Or, if it is desirable to support systems with no sysconf() and just
getdtablesize(), then:

#ifdef _SC_OPEN_MAX
int maxfd = sysconf (_SC_OPEN_MAX);
#else
int maxfd = getdtablesize ();
#endif

Jonas 'Sortie' Termansen



reply via email to

[Prev in Thread] Current Thread [Next in Thread]