X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0180339CD521 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1613121075; bh=cGfuWw2WFrw7syDCi3kROxpXb5ro8/6mfelUGMcn3vw=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=NmmtNUH4s1QCj7OxYVR5Sd+TV/X86tRfL3i27Jy/1dTpvWhsCA9o09W/VT08Q3VYQ V2OwgCFNxLxmy519kM4Tz62i07TcG8DnzPJtIzaX8HDRrJ9B12mFBCvMbh/q9362yB vV975v0UAE8GBbsOPJ0dkvtNhlmkLE+tjoSFu5Ao= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BA22739CD516 Date: Fri, 12 Feb 2021 10:11:06 +0100 To: cygwin AT cygwin DOT com Subject: Re: setrlimit always fails Message-ID: <20210212091106.GF4251@calimero.vinschen.de> Mail-Followup-To: cygwin AT cygwin DOT com References: MIME-Version: 1.0 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 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: , From: Corinna Vinschen via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Corinna Vinschen Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces AT cygwin DOT com Sender: "Cygwin" 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 -- 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