diff --git a/repos/os/doc/init.txt b/repos/os/doc/init.txt index 00f9545bb5..987e5e936f 100644 --- a/repos/os/doc/init.txt +++ b/repos/os/doc/init.txt @@ -299,6 +299,27 @@ as LOG output. To enable the verbose mode, assign the value "yes" to the 'verbose' attribute of the '' 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 '' with the attribute 'propagate' set to "yes". + +! +! +! +! ... +! +! + +The exit value specified by the exiting child is forwarded to init's parent. + + Executing children in chroot environments on Linux ================================================== diff --git a/repos/os/include/init/child.h b/repos/os/include/init/child.h index 4d7f076ff3..30b95c4349 100644 --- a/repos/os/include/init/child.h +++ b/repos/os/include/init/child.h @@ -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; } };