#define _POSIX_C_SOURCE 200809L #include #include #include #include #include #include /* Test-only deterministic launcher for allocation-failure observers. Keeping * setrlimit in a repository-built helper avoids depending on util-linux paths * or shell-specific ulimit syntax. */ int main(int argc, char **argv) { if (argc < 3) { fputs("usage: sep-limitexec bytes program [arg ...]\n", stderr); return 2; } errno = 0; char *end = NULL; unsigned long long value = strtoull(argv[1], &end, 10); if (errno != 0 || end == argv[1] || *end != '\0') { fputs("sep-limitexec: invalid limit\n", stderr); return 2; } struct rlimit limit; limit.rlim_cur = (rlim_t)value; limit.rlim_max = (rlim_t)value; if (setrlimit(RLIMIT_AS, &limit) != 0) { fputs("sep-limitexec: setrlimit failed\n", stderr); return 2; } execv(argv[2], &argv[2]); fputs("sep-limitexec: exec failed\n", stderr); return 127; }