1

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?

ycdfwzy
  • 11
  • 3
  • http://idownvotedbecau.se/nomcve/ Unclear what exactly your "C program" does and how it interacts with the code you've shown. Thus impossible to answer as the Q is now. – ivan_pozdeev Nov 30 '18 at 03:15
  • Sorry, I have added my C program now. – ycdfwzy Nov 30 '18 at 03:34
  • Related: https://github.com/raspberrypi/linux/issues/766 What do the signal details say: where does this happen, what's the source code that directly triggers the signal? – ivan_pozdeev Nov 30 '18 at 09:24

0 Answers0