From eae0445cd8af2482ea7f94b8f25853b7670938b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Thu, 26 Oct 2017 16:04:58 +0200 Subject: [PATCH] init: generate a state report when children exit Whenever a childs is terminated the exit value is propagate through a new state report. Thereby it becomes possibly for a managing component to react upon the terminating condition of a child. Issue #2558. --- repos/os/src/init/child.cc | 3 +++ repos/os/src/init/child.h | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/repos/os/src/init/child.cc b/repos/os/src/init/child.cc index 29d7b73329..11c828870c 100644 --- a/repos/os/src/init/child.cc +++ b/repos/os/src/init/child.cc @@ -281,6 +281,9 @@ void Init::Child::report_state(Xml_generator &xml, Report_detail const &detail) if (!_child.active()) xml.attribute("state", "incomplete"); + if (_exited) + xml.attribute("exited", _exit_value); + if (detail.child_ram() && _child.ram_session_cap().valid()) { xml.node("ram", [&] () { diff --git a/repos/os/src/init/child.h b/repos/os/src/init/child.h index 8b312e204b..4410ed98ff 100644 --- a/repos/os/src/init/child.h +++ b/repos/os/src/init/child.h @@ -404,6 +404,14 @@ class Init::Child : Child_policy, Routed_service::Wakeup name, *this); } + /* + * Exit state of the child set when 'exit()' is executed + * and reported afterwards through the state report. + */ + + bool _exited { false }; + int _exit_value { -1 }; + public: /** @@ -535,6 +543,14 @@ class Init::Child : Child_policy, Routed_service::Wakeup } } catch (...) { } + /* + * Trigger a new report for exited children so that any management + * component may react upon it. + */ + _exited = true; + _exit_value = exit_value; + _report_update_trigger.trigger_report_update(); + /* * Print a message as the exit is not handled otherwise. There are * a number of automated tests that rely on this message. It is