开发者

Can gdb attach a zombie process(<defunct>)?

开发者 https://www.devze.com 2023-02-20 18:04 出处:网络
I have a program who run as zombie process. I want to debug it. But I got a gdb error. mobile:/usr/local/ads5/bin# ps axf | grep ads_resolver

I have a program who run as zombie process. I want to debug it. But I got a gdb error.

mobile:/usr/local/ads5/bin# ps axf | grep ads_resolver
 558开发者_高级运维3 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.

There are my code that create the zombie process:

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; 
}


A zombie process has completed execution but the operating system is waiting for the parent to call wait(). This is just a status or a flag - the process no longer "exists" in terms of being executable.

So no it would not be possible for gdb to connect to a process that is no longer executing including a zombie process.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号