set_limit.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 17:57:59 +0100
changeset 7 a1aa30f0f904
parent 3 820ed7fb9314
child 8 96d16dfe787a
permissions -rw-r--r--
libtest demonstrates how to use shared libraries committer: Markus Bröker <mbroeker@largo.homelinux.org>

/**
 * $Id: set_limit.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $
 * $Source: /development/c/mem2swap/set_limit.c,v $
 *
 */

#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;
}