17 #ifndef _SYS_RESOURCE_H
18 #include <sys/resource.h>
28 bool succeeded(
int res) {
29 if (res == 0)
return true;
36 void dump_limitation(
const rlimit& from,
const rlimit& to)
const {
37 fprintf(stderr,
"limited resource %i to %li (was: %li of %li)\n",
50 if (succeeded(getrlimit(resource, &previous))) {
52 modified.rlim_cur = newLimit;
53 if (succeeded(setrlimit(resource, &modified))) {
54 dump_limitation(previous, modified);
60 if (succeeded(setrlimit(resource, &previous))) {
61 dump_limitation(modified, previous);
71 fputs(
"Error in ModRLimit: ", out);
72 fputs(strerror(last_errno), out);
79 #error mod_rlimit.h included twice
80 #endif // MOD_RLIMIT_H
void dump_error(FILE *out)
fputs(TRACE_PREFIX, stderr)
ModRLimit(int resource_, rlim_t newLimit)