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.
This commit is contained in:
Josef Söntgen 2017-10-26 16:04:58 +02:00 committed by Christian Helmuth
parent 3b5a34c163
commit eae0445cd8
2 changed files with 19 additions and 0 deletions

View File

@ -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", [&] () {

View File

@ -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