mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-23 15:32:25 +00:00
init: propagate exit conditions of children
This patch extends the configuration concept of init with an additional sub node for the <start> node: <start name="noux"> <exit propagate="yes"/> ... </start> If the 'propagate' attribute is set to "yes", the exit of the respective child will appear to init's parent as the exit of the entire init subsystem. Fixes #1686
This commit is contained in:
parent
686f53a5c3
commit
0f052357ef
@ -299,6 +299,27 @@ as LOG output. To enable the verbose mode, assign the value "yes" to the
|
||||
'verbose' attribute of the '<config>' node.
|
||||
|
||||
|
||||
Propagation of exit events
|
||||
==========================
|
||||
|
||||
A component can notify its parent about its graceful exit via the exit RPC
|
||||
function of the parent interface. By default, init responds to such a
|
||||
notification from one of its children by merely printing a log message but
|
||||
ignores it otherwise. However, there are scenarios where the exit of a
|
||||
particular child should result in the exit of the entire init component. To
|
||||
propagate the exit of a child to the parent of init, start nodes can host the
|
||||
optional sub node '<exit>' with the attribute 'propagate' set to "yes".
|
||||
|
||||
! <config>
|
||||
! <start name="noux">
|
||||
! <exit propagate="yes"/>
|
||||
! ...
|
||||
! </start>
|
||||
! </config>
|
||||
|
||||
The exit value specified by the exiting child is forwarded to init's parent.
|
||||
|
||||
|
||||
Executing children in chroot environments on Linux
|
||||
==================================================
|
||||
|
||||
|
@ -802,6 +802,23 @@ class Init::Child : Genode::Child_policy
|
||||
_child.notify_resource_avail();
|
||||
}
|
||||
|
||||
void exit(int exit_value) override
|
||||
{
|
||||
try {
|
||||
if (_start_node.sub_node("exit").attribute("propagate").has_value("yes")) {
|
||||
Genode::env()->parent()->exit(exit_value);
|
||||
return;
|
||||
}
|
||||
} catch (...) { }
|
||||
|
||||
/*
|
||||
* Print a message as the exit is not handled otherwise. There are
|
||||
* a number of automated tests that rely on this message. It is
|
||||
* printed by the default implementation of 'Child_policy::exit'.
|
||||
*/
|
||||
Child_policy::exit(exit_value);
|
||||
}
|
||||
|
||||
Genode::Native_pd_args const *pd_args() const { return &_pd_args; }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user