Created
February 21, 2023 15:14
-
-
Save gwisp2/aec6b92922d6e2252263e95ce507bc98 to your computer and use it in GitHub Desktop.
Revisions
-
gwisp2 created this gist
Feb 21, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #include <stdio.h> #include <unistd.h> #include <sys/syscall.h> #include <errno.h> #include <string.h> int main(int argc, char *argv[]) { if (argc < 2) { printf("No path to executable to start provided\n"); return 255; } if (syscall(SYS_close_range, 3U, ~0U, 0U)) { printf("Failed to close file descriptors: %s\n", strerror(errno)); return 255; } if (execv(argv[1], &argv[1])) { printf("Exec %s failed: %s\n", argv[1], strerror(errno)); return 255; } return 0; }