DF-5845 / pinexec.c
/* * pinexec.c -- pin self to a CPU (root) then exec. Children inherit * the lwp cpu mask across fork/exec and credential changes, so this * launches both the root rig and (via su) the opuser weapon onto the * same CPU -- the DragonFly slab allocator is per-CPU, so shaping and * allocation must meet in the same per-CPU zone list. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <sys/syscall.h> #include <sys/usched.h> int main(int argc, char **argv) { int cpu; if (argc < 3) { fprintf(stderr, "usage: pinexec <cpu> <cmd> [args...]\n"); return (2); } cpu = atoi(argv[1]); if (syscall(SYS_usched_set, 0, USCHED_SET_CPU, &cpu, sizeof(cpu)) != 0) { perror("usched_set"); return (1); } execvp(argv[2], &argv[2]); perror("execvp"); return (1); } |