gdb - gdb 可以附加一个僵尸进程(<defunct>)吗?

标签 gdb daemon zombie-process

我有一个以僵尸进程运行的程序。我想调试它。但是我遇到了 gdb 错误。

mobile:/usr/local/ads5/bin# ps axf | grep ads_resolver
 5583 pts/2    S      0:00 ./ads_resolver main.cfg
 5584 pts/2    Zl     0:36  \_ [ads_resolver] <defunct>

mobile:/usr/local/ads5/bin# gdb ads_resolver 5584
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
Attaching to program: /usr/local/ads5/bin/ads_resolver, process 5584
ptrace: Operation not permitted.
/usr/local/ads5/bin/5584: No such file or directory.
(gdb) info threads
No registers.

有我创建僵尸进程的代码:

template < class T>
int Monitor < T >::Start()
{
    pid_t pid;
    pid = fork();
    if(pid == 0)
    {
        IgnoreSignal::IgnoreDaemon();
        signal(SIGCHLD,Monitor<T>::ReStart);

        pid = fork();
        if(pid == 0)
        {
            IgnoreSignal::IgnoreAll();
            T worker;
            worker.Run();
        }
        while(1)
        {
            sleep(60);
        }
    }
    return 0; 
}

最佳答案

僵尸进程已完成执行,但操作系统正在等待父进程调用 wait()。这只是一个状态或标志 - 就可执行性而言,该进程不再“存在”。

因此,不,gdb 不可能连接到不再执行的进程,包括僵尸进程。

http://en.wikipedia.org/wiki/Zombie_process

关于gdb - gdb 可以附加一个僵尸进程(<defunct>)吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5474105/

相关文章:

Linux、waitpid、WNOHANG、子进程、僵尸

创建并获取多个子进程

c++ - GDB 以无序的方式跳到错误的行

使用 JNI 的 Java 守护线程

perl - 使用 Proc::Daemon::Init 创建一个 pid_file

php - 如何让 RabbitMQ worker 持续监听?

c - 这个程序如何创建僵尸进程?

c - 字符 : different output when run vs. 的字母顺序已调试?

c - GDB设置多个断点

linux - 我在目标系统中生成了带有调试符号的 linux 核心转储。但是我无法在主机系统中使用 GDB 调试转储