delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/02/12/02:27:07

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 683F43858031
Authentication-Results: sourceware.org; dmarc=none (p=none dis=none)
header.from=SystematicSw.ab.ca
Authentication-Results: sourceware.org;
spf=none smtp.mailfrom=brian DOT inglis AT systematicsw DOT ab DOT ca
X-Authority-Analysis: v=2.4 cv=MaypB7zf c=1 sm=1 tr=0 ts=60262d9a
a=kiZT5GMN3KAWqtYcXc+/4Q==:117 a=kiZT5GMN3KAWqtYcXc+/4Q==:17
a=IkcTkHD0fZMA:10 a=w_pzkKWiAAAA:8 a=uYT-Tk0qkVT609LjNaIA:9 a=QEXdDO2ut3YA:10
a=7yBdC4_TQmUA:10 a=6b5rHyxM8C8A:10 a=sRI3_1zDfAgwuvI8zelB:22
To: cygwin AT cygwin DOT com
References: <b0924bcb-56d0-a026-84b5-71750537facb AT fexl DOT com>
<1c233bc7-401b-568f-36d5-48c4f1d4dcea AT cornell DOT edu>
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Organization: Systematic Software
Subject: Re: setrlimit always fails
Message-ID: <42b30732-9aee-454e-3359-92a82ef09f0d@SystematicSw.ab.ca>
Date: Fri, 12 Feb 2021 00:26:16 -0700
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.7.1
MIME-Version: 1.0
In-Reply-To: <1c233bc7-401b-568f-36d5-48c4f1d4dcea@cornell.edu>
X-CMAE-Envelope: MS4xfMq9uyetQ1EZl3npF9opgjS4UMy5RuPyKju/jwVgZqu02lIwRwLRWsq1pY14HJcmPF+kkjO+dSHT1CMH63ar2gGFmKWT/bc56cl9EIOl10etYlNh2Bvz
U7rLffEJ/Jwss8C3+qzlEPyfAIxEqM0Z0B1hPkPuY0RwOq8amfBFcwZ+K7tgo+/zf186uOnrfDv8BAEGVdlr9YQGORt2REP/NQ0=
X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, BODY_8BITS,
KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_DNSWL_LOW,
RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE,
TXREP autolearn=no autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Reply-To: cygwin AT cygwin DOT com
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 11C7Qmsl032653

On 2021-02-11 19:06, Ken Brown via Cygwin wrote:
> On 2/11/2021 10:23 AM, Patrick Chkoreff wrote:
>> I'm trying to use setrlimit to impose limits on various resources such
>> as CPU time and memory.  The call to setrlimit always fails.  I've
>> distilled this into the following example test.c:
> [...]
>>      if (setrlimit(RLIMIT_CPU,&rlim) < 0)
> [...]
>> setrlimit: Invalid argument
> 
> Cygwin's setrlimit only supports a few resources, as you can see in the source:
> 
> https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/resource.cc;h=97777e9d223466b7635b990d6c9e0bfb9e2e9a46;hb=HEAD#l201 

In that case could I suggest:

	/usr/share/doc/cygwin-doc/html/cygwin-api/compatibility.html#std-susv4
	https://cygwin.com/cygwin-api/compatibility.html#std-susv4

in https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=winsup/doc/posix.xml

get/setrlimit entries should be annotated with:

	(see chapter "Implementation Notes")

and all those entries should be links to "std-notes":

	/usr/share/doc/cygwin-doc/html/cygwin-api/std-notes.html
	https://cygwin.com/cygwin-api/std-notes.html

	<ulink url="std-notes.html">(see chapter "Implementation Notes")</ulink>

in https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=winsup/doc/posix.xml

which should have an entry documenting the limitations of get/setrlimit like e.g.

"<para><function>getrlimit</function> resources RLIMIT_AS, RLIMIT_CPU, 
RLIMIT_FSIZE, RLIMIT_DATA always return rlim_cur and rlim_max as RLIM_INFINITY, 
so <function>setrlimit</function> returns -1 and sets EINVAL if they are 
lowered, or returns 0 if unchanged.
<function>getrlimit</function> resource RLIMIT_NOFILE always returns rlim_cur 
and rlim_max as OPEN_MAX; <function>setrlimit</function> returns 0 sets EINVAL 
if rlim_cur > rlim_max, does not change the value if it is RLIM_INFINITY, 
otherwise returns the result from <function>setdtablesize</function>.
<function>getrlimit</function>/<function>setrlimit</function> resources 
RLIMIT_CORE and RLIMIT_STACK return the current values and set the requested values.
All other resource arguments return -1 and set EINVAL.</para>"

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019