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: <1c233bc7-401b-568f-36d5-48c4f1d4dcea AT cornell DOT edu> From: Brian Inglis 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> Content-Language: en-CA 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 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: cygwin AT cygwin DOT com Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: cygwin-bounces AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit 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 (see chapter "Implementation Notes") 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. "getrlimit resources RLIMIT_AS, RLIMIT_CPU, RLIMIT_FSIZE, RLIMIT_DATA always return rlim_cur and rlim_max as RLIM_INFINITY, so setrlimit returns -1 and sets EINVAL if they are lowered, or returns 0 if unchanged. getrlimit resource RLIMIT_NOFILE always returns rlim_cur and rlim_max as OPEN_MAX; setrlimit returns 0 sets EINVAL if rlim_cur > rlim_max, does not change the value if it is RLIM_INFINITY, otherwise returns the result from setdtablesize. getrlimit/setrlimit resources RLIMIT_CORE and RLIMIT_STACK return the current values and set the requested values. All other resource arguments return -1 and set EINVAL." -- 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