2005-09-16 08:42:16

by Łukasz Stelmach

[permalink] [raw]
Subject: resource limits does not work?

Greetings All.

Is there anything you think I should know about setrlimit that is not
mentioned in setrlimit(2) manual that makes the malloc(3) succeed
in the code below? It fails when r.rlim_cur is less than 137840.

#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>

int main(int ac, char* av[]) {
struct rlimit r;
r.rlim_cur = 137840;
r.rlim_max = RLIM_INFINITY;
setrlimit(RLIMIT_DATA, &r);

char* a=malloc(6000000);
perror("malloc");
return 0;
}

What is more interesting is that dnscache from djbdnspackage succeeds to start
up with rlim_cur to be 0.

$ uname -a
Linux vlana 2.6.11 #1 SMP Fri Mar 4 17:35:07 CET 2005 i686 unknown unknown GNU/Linux

cheers.
PS. please CC, not a subscriber.
--
Miłego dnia
>Łukasz<