• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <sys/resource.h>
2 #include <ulimit.h>
3 #include <stdarg.h>
4 #include <unsupported_api.h>
5 
ulimit(int cmd,...)6 long ulimit(int cmd, ...)
7 {
8 	struct rlimit rl;
9 	unsupported_api(__FUNCTION__);
10 	getrlimit(RLIMIT_FSIZE, &rl);
11 	if (cmd == UL_SETFSIZE) {
12 		long val;
13 		va_list ap;
14 		va_start(ap, cmd);
15 		val = va_arg(ap, long);
16 		va_end(ap);
17 		rl.rlim_cur = 512ULL * val;
18 		if (setrlimit(RLIMIT_FSIZE, &rl)) return -1;
19 	}
20 	return rl.rlim_cur / 512;
21 }
22