#define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include "util.h" struct params { char* shared_folder; int fd[2]; int out_fd; char **argv; }; struct limits { size_t memory; int core; int time; }; struct killparams{ int time; int pid; }; #define READ_SIZE 100 char read_buf[READ_SIZE+1]; #include "ns_exec.c" #include "cgroup_prepare.c" static int killafter(void *arg) { //die when parent dies if (prctl(PR_SET_PDEATHSIG, SIGKILL)) die("cannot PR_SET_PDEATHSIG for child process: %m\n"); struct killparams* params = (struct killparams*) arg; struct timespec tw={params->time/1000,((params->time)%1000)*1000000}; struct timespec tr; nanosleep(&tw,&tr); kill(params->pid,SIGKILL); } //const size_t STACK_SIZE=1000000; #define STACK_SIZE 1000000 static char nmstack[STACK_SIZE]; static char killstack[STACK_SIZE]; static void parse_args(int argc, char **argv, struct params *params,struct limits *limits){ if (argc < 6) { puts("usage:\n starter