From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10383 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] getdtablesize: Fix returning hard instead of soft rlimit Date: Mon, 15 Aug 2016 11:33:29 -0400 Message-ID: <20160815153329.GF15995@brightrain.aerifal.cx> References: <20160813183149.6886-1-jjk@jjacky.com> <20160813192501.GE15995@brightrain.aerifal.cx> <20160813213613.3e5c068c@jjacky.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1471275229 5314 195.159.176.226 (15 Aug 2016 15:33:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 15 Aug 2016 15:33:49 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-10396-gllmg-musl=m.gmane.org@lists.openwall.com Mon Aug 15 17:33:45 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1bZJtY-0001Au-Lg for gllmg-musl@m.gmane.org; Mon, 15 Aug 2016 17:33:44 +0200 Original-Received: (qmail 21505 invoked by uid 550); 15 Aug 2016 15:33:43 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 20463 invoked from network); 15 Aug 2016 15:33:43 -0000 Content-Disposition: inline In-Reply-To: <20160813213613.3e5c068c@jjacky.com> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:10383 Archived-At: On Sat, Aug 13, 2016 at 09:36:13PM +0200, Olivier Brunel wrote: > On Sat, 13 Aug 2016 15:25:02 -0400 > Rich Felker wrote: > > > On Sat, Aug 13, 2016 at 08:31:49PM +0200, Olivier Brunel wrote: > > > --- > > > src/legacy/getdtablesize.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/src/legacy/getdtablesize.c b/src/legacy/getdtablesize.c > > > index 682da6d..b30c193 100644 > > > --- a/src/legacy/getdtablesize.c > > > +++ b/src/legacy/getdtablesize.c > > > @@ -7,5 +7,5 @@ int getdtablesize(void) > > > { > > > struct rlimit rl; > > > getrlimit(RLIMIT_NOFILE, &rl); > > > - return rl.rlim_max < INT_MAX ? rl.rlim_max : INT_MAX; > > > + return rl.rlim_cur < INT_MAX ? rl.rlim_cur : INT_MAX; > > > > Is there a motivation for this? > > > > Rich > > Well, I found this running tests for findutils, and having a couple > failing because of it. I'm not sure about possible > implications/issues it could cause in the actual tools, was only trying > to get the tests to pass (and things to work as expected), but I > wasn't facing an "actual" issue/bug, if that was the question. Given that the sysconf analog of this function uses rlim_cur rather than rlim_max, it's probably better for consistency if nothing else. It's possible we should consider dropping the implementation of getdtablesize and just having it call sysconf. This would somewhat enlarge static binaries calling getdtablesize, but the idea would be to remove the motivation to use an unspecified, deprecated, legacy function for the sake of size. Rich