set_limit.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 17:58:15 +0100
changeset 22 0db9235d68d9
parent 9 c3fecc82ade6
child 51 a03372ef9714
permissions -rw-r--r--
mysql_db is untested because we have no sponsor with a mysql database committer: Markus Bröker <mbroeker@largo.homelinux.org>

/**
 * test/demos/set_limit.c
 * Copyright (C) 2008 Markus Broeker
 */

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

int set_limit (int megs)
{
    struct rlimit rlim;

    rlim.rlim_cur = megs;
    rlim.rlim_max = 1.25 * megs;
    if (megs > (4 * 1024 * 1024))
        return setrlimit (RLIMIT_AS, &rlim);

    return -1;
}