I wrote a C program below which used execv
to run a shell command and ptrace
to trace it.
pid = fork();
if (pid == 0) {
// child process
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
char** argv = new char*[3];
argv[0] = "/usr/bin/python3.6";
argv[1] = "pythoncode.py";
argv[2] = NULL;
execv(argv[0], argv);
} else
{
// parent process
pid_t p = wait4(-1, &stat, __WALL, &rusage_);
...
}
It can work properly when I use it to run normal python code. But today, I wrote a python code below
from selenium import webdriver
browser = webdriver.Chrome()
# do something
browser.close()
I can ran it successfully in a shell or without ptrace
, but when I used execv
and ptrace
simultaneously, it always give me a stop signal and signal code was SIGILL
(Illegal Instruction). Does anyone know why and how to solve it?