Your message dated Tue, 22 Mar 2016 17:20:01 +0000 with message-id <[email protected]> and subject line Bug#818478: fixed in monit 1:5.17.1-2 has caused the Debian Bug report #818478, regarding monit: Leaves zombies around on timed out processes to be marked as done.
This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what this message is talking about, this may indicate a serious mail system misconfiguration somewhere. Please contact [email protected] immediately.) -- 818478: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=818478 Debian Bug Tracking System Contact [email protected] with problems
--- Begin Message ---Package: monit Version: 1:5.17.1-1 Severity: normal Tags: patch Hi! When a service is specified with a timeout, and that triggers, monit leaves zombies around that it will never cleanup. This is rather confusing because you are not sure if there's an actual problem with the process itself, which in this case it's with the monitoring itself. Here's a small reproducer: ,--- zombie.c --- #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { pid_t pid; pid = fork(); if (pid < 0) { fprintf(stderr, "error forking: %m\n"); exit(2); } else if (pid == 0) { _exit(0); } else { FILE *fp = fopen("/var/run/zombie.pid", "w+"); if (fp == NULL) exit(1); fprintf(fp, "%d\n", pid); fclose(fp); sleep(120); exit(0); } return 0; } `--- ,--- /etc/monit/monitrc.d/zombie --- check process zombie with pidfile /var/run/zombie.pid start program = "/root/zombie" with timeout 2 seconds mode manual `--- You should notice a normal zombie created by the zombie program, which vanishes once monit kills the process, and the other one which sticks around and never gets cleaned up. The problem is that monit does a Process_free() on timeout, which kills the process but does not wait for it, and subsequently loses track of the pid. The attached patch fixes the issue for me. Thanks, GuillemDescription: When a process times out and we kill it, we should also wait for it, otherwise we leave zombies laying around, which are a sanitary hazard at best, and very confusing at worst. Author: Guillem Jover <[email protected]> Last-Update: 2016-03-17 --- monit-5.17.1.orig/libmonit/src/system/Command.c +++ monit-5.17.1/libmonit/src/system/Command.c @@ -233,12 +233,17 @@ static Process_T _Process_new(void) { void Process_free(Process_T *P) { + int isrunning; + assert(P && *P); FREE((*P)->working_directory); - if (Process_isRunning(*P)) + isrunning = Process_isRunning(*P); + if (isrunning) Process_kill(*P); _closeParentPipes(*P); _closeStreams(*P); + if (isrunning) + Process_waitFor(*P); FREE(*P); }
--- End Message ---
--- Begin Message ---Source: monit Source-Version: 1:5.17.1-2 We believe that the bug you reported is fixed in the latest version of monit, which is due to be installed in the Debian FTP archive. A summary of the changes between this version and the previous one is attached. Thank you for reporting the bug, which will now be closed. If you have further comments please address them to [email protected], and the maintainer will reopen the bug report if appropriate. Debian distribution maintenance software pp. Sergey B Kirpichev <[email protected]> (supplier of updated monit package) (This message was generated automatically at their request; if you believe that there is a problem with it please contact the archive administrators by mailing [email protected]) -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Format: 1.8 Date: Tue, 22 Mar 2016 18:43:13 +0300 Source: monit Binary: monit Architecture: source amd64 Version: 1:5.17.1-2 Distribution: unstable Urgency: medium Maintainer: Sergey B Kirpichev <[email protected]> Changed-By: Sergey B Kirpichev <[email protected]> Description: monit - utility for monitoring and managing daemons or similar programs Closes: 818290 818478 Changes: monit (1:5.17.1-2) unstable; urgency=medium . * Fix comment in debian/conf-available/rsyslog * Change rsyslog config defaults: monitor /var/log/syslog (Closes: #818290) * Better cleanup (prevent zombies) after timeouts trigger (Closes: #818478). Thanks to Guillem Jover. Checksums-Sha1: a6a246756e46bd7527219a1abb9dcf7b31050e75 1944 monit_5.17.1-2.dsc 3d63117196ca444af653e4c1d8d0ec8e101dbdf9 29612 monit_5.17.1-2.debian.tar.xz 88bf965735d1c2abc5e33a6792750810b161d65f 544834 monit-dbgsym_5.17.1-2_amd64.deb bbe6a579ba4ca89c10bab021c0c6ebd0853e8872 283542 monit_5.17.1-2_amd64.deb Checksums-Sha256: 0ba0980456fec5368180d704d1704963cf3650b8af53455c3014a365c544a9d6 1944 monit_5.17.1-2.dsc 9176c70b47e85cbc655e42bb94d05a15f85eb1e20a83de712ad70ccfb4dcaeca 29612 monit_5.17.1-2.debian.tar.xz c384f6afacb010ab91cc609d2d0f272cec1e50ada7bbad06c12b469edaec4699 544834 monit-dbgsym_5.17.1-2_amd64.deb 9f98636fbc5ee0fe02450ca076881da04824917bd6f375e64b078dcaa060000a 283542 monit_5.17.1-2_amd64.deb Files: f1097b39fa61671ba71b392a0c6a34eb 1944 admin optional monit_5.17.1-2.dsc e8b4c25f4938cd9cb0f7328b16f64a31 29612 admin optional monit_5.17.1-2.debian.tar.xz 209a6bc16cc3407fb8c94e8187223076 544834 debug extra monit-dbgsym_5.17.1-2_amd64.deb 5fd55151d3ccf5f22001ec789de58fb1 283542 admin optional monit_5.17.1-2_amd64.deb -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCAAGBQJW8XQMAAoJEDnJoLZAJirwGAEP+wag0/gKWQwGdgGThqxuvEDu yfLTRsxG0dvb+H4S0SosStuvuPydsyVytu9sAfR1WPTeAoXfXzg3GkPGMpGrEZiY JXqXNXJ/xtV/rw+O8kJuojcn0DDlw48FBtDGF7hTWQC40eVWlJ9YcfU26lPN/eoz dThyj62cZ+TWixk0a+tjTEUhB0q8wS6OLFqXAJANagGldhaF3Ha7gt6Z2uAM7xZN /q7NTa/XBNDCjmd0ewaiD0jvbGUD6a5IrwnJU4uDFiNH2NT+M0IFIdb891bPLNpz dGcWv6DfTS3pgKnqRlgEVBe7m8+VaVwVbYnoUMQmTojcKWN0Pmymr5JffiA+DxgS 12Lb9gXPt4NJICDha9JbsE0mIB0qYEkfmnkVifFPYsydIrMJTyv9gEupW8lkHmEe y0ipAPlEtt4XxXyBeNgXETbYxEI3Hu/knKi6KJZJATsw2jUkMMFra2G656QKCLKG rz26vmAtQhWOb5QXohXN98vTT1kiLVHnGG5IOS0PHzsYaTwF0Bn7AN4LxnT5JI1H SHwatyqjpnK1RysS5B2I76dLZkLpJtXRkIpOc/QExjHEz5l+ySq+TLA9mFWrsCrG D9wK5vPMQ4cQgOsCSNv07xhqQO+H9wZ3X/G2vwrx+mycQmE1qqMiOm7A1Khzm+wq gHqa2FO4OkKDBo9dRQN0 =FOjy -----END PGP SIGNATURE-----
--- End Message ---

