From: Michal Sekletar Date: Fri, 12 Jan 2018 12:05:48 +0000 (+0100) Subject: process-util: make our freeze() routine do something useful X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=9de28371864742c2c4898a54c929781668ceba90;p=elogind.git process-util: make our freeze() routine do something useful When we crash we freeze() our-self (or possibly we reboot the machine if that is configured). However, calling pause() is very unhelpful thing to do. We should at least continue to do what init systems being doing since 70's and that is reaping zombies. Otherwise zombies start to accumulate on the system which is a very bad thing. As that can prevent admin from taking manual steps to reboot the machine in somewhat graceful manner (e.g. manually stopping services, unmounting data volumes and calling reboot -f). Fixes #7783 --- diff --git a/src/basic/process-util.c b/src/basic/process-util.c index c4a69f261..3746f224a 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -960,6 +960,17 @@ noreturn void freeze(void) { sync(); + /* Let's not freeze right away, but keep reaping zombies. */ + for (;;) { + int r; + siginfo_t si = {}; + + r = waitid(P_ALL, 0, &si, WEXITED); + if (r < 0 && errno != EINTR) + break; + } + + /* waitid() failed with an unexpected error, things are really borked. Freeze now! */ for (;;) pause(); }