I have a reproducible situation where a compiler instance goes into a zombie state when I rebuild a package, but gdb won't permit me to attach:
serenity ~ # ps ax | grep defunct 11351 pts/1 Z+ 0:00 [x86_64-pc-linux] <defunct> 21838 pts/5 S+ 0:00 grep --colour=auto defunct serenity ~ # gdb -p 11351 GNU gdb (Gentoo 7.10.1 vanilla) 7.10.1 [snip] Attaching to process 11351 warning: process 11351 is a zombie - the process has already terminated ptrace: Operation not permitted. (gdb) This question suggests the problem is with proc.sys.kernel.yama.ptrace_scope, or that I might not be root, but that sysctl isn't present on my system, and I am running as root:
serenity ~ # sysctl -a | grep ptrace sysctl: reading key "net.ipv6.conf.all.stable_secret" sysctl: reading key "net.ipv6.conf.default.stable_secret" sysctl: reading key "net.ipv6.conf.enp4s0.stable_secret" sysctl: reading key "net.ipv6.conf.lo.stable_secret" serenity ~ # whoami root serenity ~ # For reference, my kernel version is 4.9.16-gentoo.