~ubuntu-branches/ubuntu/trusty/musl/trusty-proposed

« back to all changes in this revision

Viewing changes to src/legacy/ulimit.c

  • Committer: Package Import Robot
  • Author(s): Kevin Bortis
  • Date: 2013-09-20 20:54:14 UTC
  • Revision ID: package-import@ubuntu.com-20130920205414-5b61trtmma18w58o
Tags: upstream-0.9.13
ImportĀ upstreamĀ versionĀ 0.9.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <sys/resource.h>
 
2
#include <ulimit.h>
 
3
#include <stdarg.h>
 
4
 
 
5
long ulimit(int cmd, ...)
 
6
{
 
7
        struct rlimit rl;
 
8
        getrlimit(RLIMIT_FSIZE, &rl);
 
9
        if (cmd == UL_SETFSIZE) {
 
10
                long val;
 
11
                va_list ap;
 
12
                va_start(ap, cmd);
 
13
                val = va_arg(ap, long);
 
14
                va_end(ap);
 
15
                rl.rlim_cur = 512ULL * val;
 
16
                if (setrlimit(RLIMIT_FSIZE, &rl)) return -1;
 
17
        }
 
18
        return rl.rlim_cur / 512;
 
19
}