DF-2799 / listonce.c
/* * DF-2799 marker #1: a single `jail.list` read. Uses the raw * __sysctl(202) path so it works with /usr/bin/sysctl busy or wedged. * Expected on the deadlocked kernel: NEVER returns (blocks in * sysctl_jail_list on jail_lock) -> `timeout N ./listonce` exits 124. * On a healthy/patched kernel: returns immediately, rc 0. */ #include <sys/sysctl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { static char buf[1 << 18]; size_t len = sizeof(buf); int name[3]; size_t namelen = 0; /* jail.list */ name[namelen++] = 1; /* CTL_KERN */ name[namelen++] = 33; /* jail node OID (from mib lookup) */ name[namelen++] = 1; /* .list — resolved below by name */ /* do it by name to avoid hardcoding the mib numbers */ if (sysctlbyname("jail.list", buf, &len, NULL, 0) < 0) { perror("sysctl jail.list"); return (1); } printf("listonce: ok (%zu bytes)\n", len); return (0); } |