Subject: bug#36838: mcron leaves zombies around

From: Robert Vollmert <[email-masked]>
Date: Mon, 29 Jul 2019 17:39:33 +0200

It seems that mcron doesn’t clean up after itself. I regularly see
some zombie processes around, presumably left over by each of my
two 15-minute cron jobs:

root     21285  0.0  0.3  24124  3248 ?        Ss   11:05   0:00 /gnu/store/mamwayq00mqs85kgs6ibww7xw6dy776s-mcron-1.1.1/bin/mcron /gnu/store/rdi71izz4d16v77hb8h2jks0s3q9zini-mcron-job /gnu/store/k7dn1v7qpi4kz183glmbgsf1c7pj19xx-mcron-job /gnu/store/lfyj23bzhc14y5rqi91g493jql9dphxk-mcron-job /gnu/store/mx9k5n92kmhryn3vh4607hrmnkjb8dl6-mcron-job /gnu/store/l4nxmajr0i5g07fxvrgnaw29zd1jq0qw-mcron-job
root     26611  0.0  0.0      0     0 ?        Z    17:29   0:00 [mcron] <defunct>
root     26612  0.0  0.0      0     0 ?        Z    17:29   0:00 [mcron] <defunct>

In case that matters, they’re defined using the following:

(define puzzledb-tweets-pzv-job
  (let* ((exp
          (with-imported-modules '((helpers))
            #~(begin
                (use-modules (helpers))
                (let ((backend (read-secret "tools.jwt"))
                      (twitter (read-secret "twitter.token")))
                  (runl (string-append #$puzzledb-tools "/bin/tweets")
                        "-backend_token" backend
                        "-token" twitter
                        "-deletes")))))
         (script (program-file "puzzledb-tweets-pzv-job" exp)))
    #~(job "*/15 * * * *" ; every fifteen minutes
           #$script)))

where the module helpers contains:

(define-module (helpers)
  #:use-module (ice-9 textual-ports)
  #:export (runl read-secret))

(define* (runl prog . args)
  (apply execl prog prog args))

(define* (read-secret file)
  (string-trim-both
    (get-string-all
      (open-input-file
        (string-append "/etc/puzzledb/secrets/" file)))))