1 #define _POSIX_C_SOURCE 200809L
2 
3 #include <cstdio>
4 #include <cstdlib>
5 #include <cstring>
6 #include <libgen.h>
7 #include <string>
8 #include <unistd.h>
9 
10 int main(int argc, char const **argv) {
11   char *buf = strdup(argv[0]); // Set breakpoint 1 here
12   std::string directory_name(::dirname(buf));
13 
14   std::string other_program = directory_name + "/secondprog";
15   argv[0] = other_program.c_str();
16   execv(argv[0], const_cast<char *const *>(argv));
17   perror("execve");
18   abort();
19 }
20