teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0604-process-util-make-our-freeze-routine-do-something-us.patch

923a60
From 04213418a4e8d4e7f74f5b8b03713172a658d9e4 Mon Sep 17 00:00:00 2001
923a60
From: Michal Sekletar <msekleta@redhat.com>
923a60
Date: Fri, 12 Jan 2018 13:05:48 +0100
923a60
Subject: [PATCH] process-util: make our freeze() routine do something useful
923a60
923a60
When we crash we freeze() our-self (or possibly we reboot the machine if
923a60
that is configured). However, calling pause() is very unhelpful thing to
923a60
do. We should at least continue to do what init systems being doing
923a60
since 70's and that is reaping zombies. Otherwise zombies start to
923a60
accumulate on the system which is a very bad thing. As that can prevent
923a60
admin from taking manual steps to reboot the machine in somewhat
923a60
graceful manner (e.g. manually stopping services, unmounting data
923a60
volumes  and calling reboot -f).
923a60
923a60
Fixes #7783
923a60
923a60
(cherry picked from commit 8647283e453e4039029e2b21270241fa4010b3d8)
923a60
923a60
Resolves: #1540941
923a60
---
923a60
 src/shared/util.c | 11 +++++++++++
923a60
 1 file changed, 11 insertions(+)
923a60
923a60
diff --git a/src/shared/util.c b/src/shared/util.c
923a60
index 39359fcc8a..af09532733 100644
923a60
--- a/src/shared/util.c
923a60
+++ b/src/shared/util.c
923a60
@@ -4158,6 +4158,17 @@ noreturn void freeze(void) {
923a60
 
923a60
         sync();
923a60
 
923a60
+        /* Let's not freeze right away, but keep reaping zombies. */
923a60
+        for (;;) {
923a60
+                int r;
923a60
+                siginfo_t si = {};
923a60
+
923a60
+                r = waitid(P_ALL, 0, &si, WEXITED);
923a60
+                if (r < 0 && errno != EINTR)
923a60
+                        break;
923a60
+        }
923a60
+
923a60
+        /* waitid() failed with an unexpected error, things are really borked. Freeze now! */
923a60
         for (;;)
923a60
                 pause();
923a60
 }