- struct rlimit lim; /* getrlimit values */
- unsigned long long vs_cpu;
- uint32_t cpu_sched_flags;
-
- if (slr != 0) {
- /* set memory limits */
- getrlimit(RLIMIT_RSS,&lim);
- if (adjust_lim(&slr->vs_rss, &lim)) {
- setrlimit(RLIMIT_RSS, &lim);
- if (vc_set_rlimit(ctx, RLIMIT_RSS, &slr->vs_rss))
- {
- PERROR("pl_setrlimit(%u, RLIMIT_RSS)", ctx);
- exit(1);
- }
- }
-
- /* set address space limits */
- getrlimit(RLIMIT_AS,&lim);
- if (adjust_lim(&slr->vs_as, &lim)) {
- setrlimit(RLIMIT_AS, &lim);
- if (vc_set_rlimit(ctx, RLIMIT_AS, &slr->vs_as))
- {
- PERROR("pl_setrlimit(%u, RLIMIT_AS)", ctx);
- exit(1);
- }
- }
- /* set nrpoc limit */
- getrlimit(RLIMIT_NPROC,&lim);
- if (adjust_lim(&slr->vs_nproc, &lim)) {
- setrlimit(RLIMIT_NPROC, &lim);
- if (vc_set_rlimit(ctx, RLIMIT_NPROC, &slr->vs_nproc))
- {
- PERROR("pl_setrlimit(%u, RLIMIT_NPROC)", ctx);
- exit(1);
- }
- }
+ struct rlimit lim;
+ getrlimit(resource, &lim);
+ adjust_lim(limit, &lim);
+ setrlimit(resource, &lim);
+}