This could be seen as a bug in GNU Guix (or Nix?) as well but, the test suite of ngircd uses some "kill -0" calls to determine whether a process is still alive after receiving a SIGTERM, and that doesn't work in Guix's build processes because it's a strongly encapsulated environment in which PID 1 is a Guile process running a certain script which apparently doesn't fulfill the expected role, of a real PID 1 (init) process, to wait(2) for disowned and killed processes, which makes them turn into zombies.
I don't know of a trivial solution, so do as you wish. :-) (The Guix recipe will just disable the running of 'make check' for now.)
Taylan
Hi Taylan!
Am 04.02.2015 um 22:32 schrieb "Taylan Ulrich Bayırlı/Kammer" taylanbayirli@gmail.com:
This could be seen as a bug in GNU Guix (or Nix?) as well but, the test suite of ngircd uses some "kill -0" calls to determine whether a process is still alive after receiving a SIGTERM, and that doesn't work in Guix's build processes because it's a strongly encapsulated environment in which PID 1 is a Guile process running a certain script which apparently doesn't fulfill the expected role, of a real PID 1 (init) process, to wait(2) for disowned and killed processes, which makes them turn into zombies.
I don't know of a trivial solution, so do as you wish. :-) (The Guix recipe will just disable the running of 'make check' for now.)
Thanks for your report!
Does "pgrep(1)" see the zombie processes as well? If not, we could probably use pgrep instead of killall ...
Alex
Alexander Barton alex@barton.de writes:
Does "pgrep(1)" see the zombie processes as well?
Yes; they're recognized by pgrep(1), ps(1), etc..
However, they're listed with process state 'Z' by ps(1), so if we can portably control ps(1) output we might be able to filter them out. That is assuming this state flag 'Z' is portable across *nix systems.
POSIX under-specifies ps(1) and doesn't define a field-name for the process state for the -o switch, but on XSI conforming systems it's specified to be the second column when the -l switch is used. (What the hell, POSIX; if it's one of the fields you recognize, why don't you give it a name for the -o switch? I don't get it.)
So if we can rely on XSI conformance plus state 'Z' for zombie, then the following shell functions should work:
process_is_alive(){ ! process_is_dead "$1" && ! process_is_undead "$1" }
process_is_dead(){ ! kill -0 "$1" }
process_is_undead(){ ps -p "$1" -l | { read _ # ignore column headers read _ state _ case $state in (Z*) true ;; (*) false; esac } }
This works on Debian (and should work on SunOS according to manpages).
However, BSDs apparently don't conform to POSIX.2008/XSI. Another option would be to rely on the -o switch accepting "state", which seems portable across GNU, BSD, and Sun, but I don't know about A/UX or any other platforms you intend to support. Should that variant be realized, the `process_is_undead' function would instead be:
process_is_undead(){ case $(ps -p "$1" -o state=) in (Z*) true ;; (*) false ;; esac }
Hope that helps.
Taylan
Correction on my previous e-mail:
SunOS ps(1) uses the name "s" for the -o switch for the state field, not "state" like GNU and BSD.
(By the way Mac OS X falls under BSD in this context.)
Taylan