diff --git a/repos/base/include/base/env.h b/repos/base/include/base/env.h index da9657cd00..3bcf083fc1 100644 --- a/repos/base/include/base/env.h +++ b/repos/base/include/base/env.h @@ -145,6 +145,33 @@ struct Genode::Env * executes this function before constructing libc components. */ virtual void exec_static_constructors() = 0; + + /** + * Reload parent capability and reinitialize environment resources + * + * This method is solely used for implementing fork in Noux. After forking + * a process, the new child process is executed within a copy of the + * address space of the forking process. Thereby, the new process inherits + * the original 'env' object of the forking process, which is meaningless + * in the context of the new process. By calling this function, the new + * process is able to reinitialize its 'env' with meaningful capabilities + * obtained via its updated parent capability. + * + * \noapi + */ + virtual void reinit(Native_capability::Raw) = 0; + + /** + * Reinitialize main-thread object + * + * \param stack_area_rm new region map of the stack area + * + * This function is solely used for implementing fork as provided by the + * Noux environment. + * + * \noapi + */ + virtual void reinit_main_thread(Capability &stack_area_rm) = 0; }; #endif /* _INCLUDE__BASE__ENV_H_ */ diff --git a/repos/base/src/lib/base/component.cc b/repos/base/src/lib/base/component.cc index 3c01aae625..a7e0d80aac 100644 --- a/repos/base/src/lib/base/component.cc +++ b/repos/base/src/lib/base/component.cc @@ -99,6 +99,16 @@ namespace { return Genode::env_session_id_space(); } + void reinit(Native_capability::Raw raw) override + { + Genode::env_deprecated()->reinit(raw); + } + + void reinit_main_thread(Capability &stack_area_rm) override + { + Genode::env_deprecated()->reinit_main_thread(stack_area_rm); + } + void _block_for_session() { /* diff --git a/repos/libports/src/app/qt5/qt_launchpad/main.cpp b/repos/libports/src/app/qt5/qt_launchpad/main.cpp index febf2d7b83..569f9aa707 100644 --- a/repos/libports/src/app/qt5/qt_launchpad/main.cpp +++ b/repos/libports/src/app/qt5/qt_launchpad/main.cpp @@ -56,6 +56,14 @@ struct Qt_launchpad_namespace::Local_env : Genode::Env void close(Parent::Client::Id id) { return genode_env.close(id); } void exec_static_constructors() override { } + + void reinit(Native_capability::Raw raw) override { + genode_env.reinit(raw); + } + + void reinit_main_thread(Capability &stack_area_rm) override { + genode_env.reinit_main_thread(stack_area_rm); + } }; diff --git a/repos/libports/src/lib/libc/task.cc b/repos/libports/src/lib/libc/task.cc index 77f366b45e..9aa67f53fa 100644 --- a/repos/libports/src/lib/libc/task.cc +++ b/repos/libports/src/lib/libc/task.cc @@ -161,6 +161,12 @@ class Libc::Env_implementation : public Libc::Env /* already done by the libc */ void exec_static_constructors() override { } + + void reinit(Native_capability::Raw raw) override { + _env.reinit(raw); } + + void reinit_main_thread(Capability &stack_area_rm) override { + _env.reinit_main_thread(stack_area_rm); } };