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 <stdio.h>
> #include <stdlib.h>
> #include <sys/resource.h>
> 
> 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

Reply via email to