summaryrefslogtreecommitdiff
path: root/src/basic/process-util.c
diff options
context:
space:
mode:
authorMichal Sekletar <msekleta@redhat.com>2018-01-12 13:05:48 +0100
committerLennart Poettering <lennart@poettering.net>2018-01-12 17:50:02 +0100
commit8647283e453e4039029e2b21270241fa4010b3d8 (patch)
tree890f6271951adbef02cca04b8652d41995970d20 /src/basic/process-util.c
parent47e5995a38c68d21604c67c1eb1231f26ea051e9 (diff)
downloadsystemd-8647283e453e4039029e2b21270241fa4010b3d8.tar.gz
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
Diffstat (limited to 'src/basic/process-util.c')
-rw-r--r--src/basic/process-util.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index 9fc5464665..dc7c9ef9ef 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -949,6 +949,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();
}