From 73f9bb73cd1c9e18b22eaa975aac15e467936530 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Wed, 15 Jul 2015 10:30:44 +0200 Subject: [PATCH] init: don't block for resource upgrades If some sessions run out of memory in init, resource requests will be issued to core, which it never will satisfy. Setting some default signal handler avoids that the default implementation will block init for ever. Issue #1632 --- repos/os/src/init/main.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/repos/os/src/init/main.cc b/repos/os/src/init/main.cc index e0a779a2ec..b8453b613c 100644 --- a/repos/os/src/init/main.cc +++ b/repos/os/src/init/main.cc @@ -294,8 +294,11 @@ int main(int, char **) * Signal receiver for config changes */ Signal_receiver sig_rec; - Signal_context sig_ctx; - config()->sigh(sig_rec.manage(&sig_ctx)); + Signal_context sig_ctx_config; + Signal_context sig_ctx_res_avail; + config()->sigh(sig_rec.manage(&sig_ctx_config)); + /* prevent init to block for resource upgrades (never satisfied by core) */ + env()->parent()->resource_avail_sigh(sig_rec.manage(&sig_ctx_res_avail)); for (;;) { @@ -364,7 +367,13 @@ int main(int, char **) */ /* wait for config change */ - sig_rec.wait_for_signal(); + while (true) { + Signal signal = sig_rec.wait_for_signal(); + if (signal.context() == &sig_ctx_config) + break; + + PWRN("unexpected signal received - drop it"); + } /* kill all currently running children */ while (children.any()) {