delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/02/12/13:57:03

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 865E23857C75
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=6026cf4d
a=kiZT5GMN3KAWqtYcXc+/4Q==:117 a=kiZT5GMN3KAWqtYcXc+/4Q==:17
a=IkcTkHD0fZMA:10 a=w_pzkKWiAAAA:8 a=TImcKGuyeGIbufSLrCcA:9
a=rZlNn1G1URmHCcgV:21 a=60vp6XjTXxwm7x_0:21 a=QEXdDO2ut3YA:10
a=7yBdC4_TQmUA: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>
<42b30732-9aee-454e-3359-92a82ef09f0d AT SystematicSw DOT ab DOT ca>
<20210212091233 DOT GG4251 AT calimero DOT vinschen DOT de>
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Organization: Systematic Software
Subject: Re: setrlimit always fails
Message-ID: <5dc9c6fa-dee6-94a1-e3ee-e73eb6096047@SystematicSw.ab.ca>
Date: Fri, 12 Feb 2021 11:56:12 -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: <20210212091233.GG4251@calimero.vinschen.de>
X-CMAE-Envelope: MS4xfP+vnehKh8xGaV/Tfk+BL20aYsNcBAGWdYL2oIQCGnRj59bjHtkijWRNDuL1j54F7u2Fi/GkPCUmmt8lPeKB+4MuN6FgJn1horIfDoe/UwobQgEVszcJ
XOgNjQs/BIzaWZNIIh+b+Hw7QZanL53GyZa/LuO39vfeTTaZQWyT+UgCc+7CBQuxopYmZNn81NdrgcJ0SB5f21613YTu498MZAo=
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 11CIujOY019975

On 2021-02-12 02:12, Corinna Vinschen via Cygwin wrote:
> On Feb 12 00:26, Brian Inglis wrote:
>> 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:
> 
> https://cygwin.com/acronyms/#PGA

I'll see what I can do. Does anyone know if <ulink> is supported within 
<screen>? I seem to remember struggles updating proc(5) in specialnames.xml.

It appears that code using other than the common POSIX resources need existence 
checks.
I am unsure if it is worth adding definitions for any others.
It may be possible to implement RSS, NPROC, LOCKS, NICE, but
https://cygwin.com/acronyms/#SHDTI

Comparing Cygwin and Linux ([uapi/]asm-generic/}:

#define RLIMIT_CPU		0	/* CPU time in seconds */
#define RLIMIT_FSIZE		1	/* Maximum filesize */
#define RLIMIT_DATA		2	/* max data size */
#define RLIMIT_STACK		3	/* max stack size */
#define RLIMIT_CORE		4	/* max core file size */
#ifdef LINUX
#define RLIMIT_RSS		5	/* max resident set size */
#define RLIMIT_NPROC		6	/* max number of processes */
#define RLIMIT_NOFILE		7	/* max number of open files */
#define RLIMIT_AS		9	/* address space limit */
#else
#define RLIMIT_NOFILE		5	/* max number of open files */
#define RLIMIT_OFILE		RLIMIT_NOFILE	/* BSD name */
#define RLIMIT_AS		6	/* address space limit */
#endif
#ifdef LINUX
#define RLIMIT_LOCKS		10	/* maximum file locks held */
#define RLIMIT_SIGPENDING	11	/* max number of pending signals */
#define RLIMIT_MSGQUEUE		12	/* maximum bytes in POSIX mqueues */
#define RLIMIT_NICE		13	/* max nice prio allowed to raise to */
#define RLIMIT_RTPRIO		14	/* maximum realtime priority */
#define RLIMIT_RTTIME		15	/* timeout for RT tasks in us */
#define RLIM_NLIMITS		16
#else
#define RLIMIT_NLIMITS		7	/* upper bound of RLIMIT_* defines */
#endif

Linux man says:

"RLIMIT_MEMLOCK and RLIMIT_NPROC derive from BSD and are not specified in 
POSIX.1; they are present on the BSDs and Linux, but on few other implementations.
RLIMIT_RSS derives from BSD and is not specified in POSIX.1; it is nevertheless 
present on most implementations.
RLIMIT_MSGQUEUE, RLIMIT_NICE, RLIMIT_RTPRIO,  RLIMIT_RTTIME, and 
RLIMIT_SIGPENDING are Linux-specific."

-- 
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