#include #include #include #include #include #include // ./dumpable => returns current dumpable // ./dumpable [0|1|2] [args...] => executes cmd under dumpable state // and with RLIMIT_CPU=0 int main(int argc, char **argv, char **envp) { struct rlimit lim; if (argc < 2) { printf("dumpable=%d\n", prctl(PR_GET_DUMPABLE, 0, 0, 0, 0)); return 0; } prctl(PR_SET_DUMPABLE, atoi(argv[1]), 0, 0, 0); lim.rlim_cur = RLIM_INFINITY; lim.rlim_max = RLIM_INFINITY; setrlimit(RLIMIT_CORE, &lim); lim.rlim_cur = 0; lim.rlim_max = RLIM_INFINITY; setrlimit(RLIMIT_CPU, &lim); return execve(argv[2], argv + 2, envp); }