code-intelligence.com/cifuzz@v0.40.0/pkg/minijail/process_wrapper/src/process_wrapper.c (about) 1 #include <errno.h> 2 #include <stdio.h> 3 #include <string.h> 4 #include <unistd.h> 5 6 // Executes argv[2] with argv[3..argc-1] as arguments after changing the 7 // working directory to argv[1]. 8 int main(int argc, char **argv) { 9 if (argc < 3) { 10 fprintf(stderr, 11 "Usage: %s <directory> <executable_path> <executable_arg1> ...\n", 12 argv[0]); 13 return 1; 14 } 15 16 if (chdir(argv[1]) == -1) { 17 fprintf(stderr, "chdir(%s) failed: %s\n", argv[1], strerror(errno)); 18 return 1; 19 } 20 21 // Skip over both the process wrapper's own argv[0] and the directory. 22 if (execv(argv[2], argv + 2) == -1) { 23 fprintf(stderr, "execv(%s) failed: %s\n", argv[2], strerror(errno)); 24 return 1; 25 } 26 // Not reached. 27 }