Files
llvm-project/lldb/test/API/functionalities/exec/main.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
472 B
C++
Raw Normal View History

#define _POSIX_C_SOURCE 200809L
2019-07-25 06:38:33 +00:00
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <libgen.h>
#include <string>
2019-07-25 06:38:33 +00:00
#include <unistd.h>
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";
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();
}