From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.135]) by sourceware.org (Postfix) with ESMTPS id BA22739CD516 for ; Fri, 12 Feb 2021 09:11:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BA22739CD516 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N5mOZ-1lywOe0fHv-017CnK for ; Fri, 12 Feb 2021 10:11:07 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id 67E41A80D37; Fri, 12 Feb 2021 10:11:06 +0100 (CET) Date: Fri, 12 Feb 2021 10:11:06 +0100 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: setrlimit always fails Message-ID: <20210212091106.GF4251@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:J849i3i+3Ez1oPZu/7trABpD4FOMDNKuRY3GWMng4h7MzNeie1z /URnsXPuOSL+7vQn1Wc6FgbfWpzxBe2Hddjz+xLtoXXVj/cSufmUrc3ar1E5/uAilZK4hDm oYPSFobiwyMEMAteVXadFgs5K/UUx9fRtBsIYBAc9N2sRZhBFR3+RCFZDjGNDWOjUy0AeEX Q/5axNkfUArUAM2/V6Yqw== X-UI-Out-Filterresults: notjunk:1;V03:K0:dz8ktVutLjo=:JUk69IN06zBiqp7VYoUEf7 4VngrWnia/OKdVnHfd0OhCnA1JzTz+mOzVzTwVi30JJf436ZgCrujsC+GyUHza8W83576ofw1 KWSyiyDYtOUeDYjgun+hcMke1ZaUxoA5uBKRxy/FebqsmieKXWwvunHpPZRuPbZbV+WF8H9Ua HpmAW98mYsFniZs7GBx+pPVBNBEozf19vBrh98tmyKlOY5kji+jq7asT7EZ4ksnlcIem+F1eJ GE8q16tB3W+c4eWdgXm0F3qPy5Q2A69ZtnblvFAf1eOIaVxtJ7eVvXBOV6537R+3ig3NGdiD6 Mh82uMcTV78sF2bNJGaVzjAwA4xK4UnRPqtN1Hlj2VrURNjfIKdJne21M+YbhafKB0ZG7jwUF 8tcAuIvalbwP/dhYK9/JkB7QCA8ZHrKdI3WE/C2iA+MXWm4Nu6ZDO9Er5BflHcMtvhMGdnCre SqBTfdPIV4vmMKOxDPx0mmvPwcg//AGsQBd9aXgNIQGffXY5PS3YcQTbGHvz6xaUpiqjhxJoL A== X-Spam-Status: No, score=-101.0 required=5.0 tests=BAYES_00, GOOD_FROM_CORINNA_CYGWIN, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham 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@cygwin.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: , X-List-Received-Date: Fri, 12 Feb 2021 09:11:13 -0000 On Feb 11 10:23, 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: > > #include > #include > #include > > int main(void) > { > struct rlimit rlim; > rlim.rlim_cur = 1; > rlim.rlim_max = 1; > if (setrlimit(RLIMIT_CPU,&rlim) < 0) > { > perror("setrlimit"); > exit(1); > } > printf("HEY\n"); > while (1) > { > } > printf("BYE\n"); > return 0; > } > > $ gcc test.c > $ ./a.exe > setrlimit: Invalid argument > > > I have found that the only way to make the setrlimit call succeed is to > use RLIM_INFINITY: > > rlim.rlim_cur = RLIM_INFINITY; > rlim.rlim_max = RLIM_INFINITY; > > But then of course it does not achieve the desired result of timing out > after 1 second. > > Any ideas? Most of setrlimit is not supported. There's a bit of RLIMIT_CORE and RLIMIT_NOFILE support but it's basically fake because Windows doesn't (or didn't in some cases) have support for setting limits for the own and child processes. Corinna