How do I debug the child process after fork() in gdb?

后端 未结 1 967
抹茶落季
抹茶落季 2020-12-02 23:18

After calling fork,the current process will call exit(0).

But the child will continue.

switch(fork())
{
  case -1:
    exit(1);
  case 0         


        
相关标签:
1条回答
  • 2020-12-02 23:42

    Look at this. Use:

    set follow-fork-mode <mode>
    

    Set the debugger response to a program call of fork or vfork. A call to fork or vfork creates a new process. The <mode> argument can be:

    parent: The original process is debugged after a fork. The child process runs unimpeded. This is the default.

    child: The new process is debugged after a fork. The parent process runs unimpeded.

    0 讨论(0)
提交回复
热议问题