如何调试在gdb的fork()的后子进程? [英] How do I debug the child process after fork() in gdb?

查看:1094
本文介绍了如何调试在gdb的fork()的后子进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用fork后,当前进程将调用退出(0)

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

但孩子会继续。

switch(fork())
{
  case -1:
    exit(1);
  case 0:
    //child process,continue
    break;
  default:
    //the current process,exit
    exit(0);
}

我如何继续调试子进程在这种情况下?

How can I continue debug the child process in this case?

推荐答案

这个。用途:

set follow-fork-mode <mode>

设置调试程序响应叉子或vfork的的程序调用。一个调用fork或vfork的创建一个新的进程。在&LT;模式&gt; 参数可以是:

:原工艺是fork之后调试。子进程的运行不受影响。这是默认的。

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

孩子:新的过程,是一个fork之后调试。父进程运行畅通。

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

这篇关于如何调试在gdb的fork()的后子进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆