Oh yeah, I've once discovered this method myself. With execveat() one can even avoid going through procfs.
It doesn't work worth shbang-based scripts, though; that just returns ENOENT. Makes sense, I suppose.
It doesn't work worth shbang-based scripts, though; that just returns ENOENT. Makes sense, I suppose.
snprintf(pathbuf, sizeof(pathbuf), "/proc/self/fd/%u", fd);
execve(pathbuf, argv, envp);
you do execveat(fd, "", argv, envp, AT_EMPTY_PATH);
and that's it.