2019-11-29 14:11:39 +03:00
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
|
|
2019-07-25 06:38:33 +00:00
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <cstring>
|
2018-06-15 00:55:53 +00:00
|
|
|
#include <libgen.h>
|
|
|
|
|
#include <string>
|
2019-07-25 06:38:33 +00:00
|
|
|
#include <unistd.h>
|
2013-05-21 21:55:59 +00:00
|
|
|
|
2019-07-25 06:38:33 +00:00
|
|
|
int main(int argc, char const **argv) {
|
|
|
|
|
char *buf = strdup(argv[0]); // Set breakpoint 1 here
|
|
|
|
|
std::string directory_name(::dirname(buf));
|
|
|
|
|
|
|
|
|
|
std::string other_program = directory_name + "/secondprog";
|
2020-04-27 14:38:32 +02:00
|
|
|
argv[0] = other_program.c_str();
|
|
|
|
|
execv(argv[0], const_cast<char *const *>(argv));
|
2019-07-25 06:38:33 +00:00
|
|
|
perror("execve");
|
|
|
|
|
abort();
|
2013-05-21 21:55:59 +00:00
|
|
|
}
|