Core: exit with child exit value

Effective for base-linux only.
This commit is contained in:
Ehmry - 2019-07-24 11:38:05 +02:00
parent 4a7b0e99a6
commit 4952b37e4c
17 changed files with 44 additions and 22 deletions

View File

@ -167,7 +167,7 @@ namespace Genode {
size_t max_caps() const override { return Capability_space::max_caps(); }
void wait_for_exit() override;
void wait_for_exit(int const &) override;
};
}

View File

@ -483,7 +483,7 @@ Platform::Platform() :
** Generic platform interface **
********************************/
void Platform::wait_for_exit()
void Platform::wait_for_exit(int const &)
{
/*
* On Fiasco, Core never exits. So let us sleep forever.

View File

@ -183,7 +183,7 @@ namespace Genode {
Cap_id_allocator &cap_id_alloc() { return _cap_id_alloc; }
void wait_for_exit() override;
void wait_for_exit(int const &) override;
};
}

View File

@ -582,7 +582,7 @@ Platform::Platform() :
** Generic platform interface **
********************************/
void Platform::wait_for_exit()
void Platform::wait_for_exit(int const &)
{
/*
* On Fiasco, Core never exits. So let us sleep forever.

View File

@ -128,7 +128,7 @@ class Genode::Platform : public Genode::Platform_generic
size_t vm_size() const override { return Hw::Mm::user().size; }
Rom_fs &rom_fs() override { return _rom_fs; }
void wait_for_exit() override {
void wait_for_exit(int const &) override {
while (1) { Kernel::stop_thread(); } };
bool supports_direct_unmap() const override { return true; }

View File

@ -129,7 +129,9 @@ namespace Genode {
*/
size_t max_caps() const override { return 10000; }
void wait_for_exit() override;
void wait_for_exit(int const &) override;
void child_exit() override;
};
}

View File

@ -113,7 +113,7 @@ Platform::Platform()
}
void Platform::wait_for_exit()
void Platform::wait_for_exit(int const &exit_value)
{
for (;;) {
@ -145,9 +145,11 @@ void Platform::wait_for_exit()
Platform_thread::submit_exception(pid);
}
}
lx_exit_group(0);
lx_exit_group(exit_value);
}
void Platform::child_exit() { sigint_handler(0); }
/*****************************
** Support for IPC library **

View File

@ -82,7 +82,7 @@ namespace Genode {
size_t vm_size() const override { return _vm_size; }
Rom_fs &rom_fs() override { return _rom_fs; }
size_t max_caps() const override { return _max_caps; }
void wait_for_exit() override;
void wait_for_exit(int const &) override;
bool supports_direct_unmap() const override { return true; }

View File

@ -993,5 +993,5 @@ bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t, unsigned size)
** Generic platform interface **
********************************/
void Platform::wait_for_exit() { sleep_forever(); }
void Platform::wait_for_exit(int const &) { sleep_forever(); }

View File

@ -139,7 +139,7 @@ namespace Genode {
Rom_fs &rom_fs() override { return _rom_fs; }
size_t max_caps() const override { return Capability_space::max_caps(); }
void wait_for_exit() override;
void wait_for_exit(int const &) override;
bool supports_direct_unmap() const override { return true; }

View File

@ -215,7 +215,7 @@ Platform::Platform()
** Generic platform interface **
********************************/
void Platform::wait_for_exit()
void Platform::wait_for_exit(int const &)
{
/*
* On OKL4, core never exits. So let us sleep forever.

View File

@ -153,7 +153,7 @@ namespace Genode {
Rom_fs &rom_fs() override { return _rom_fs; }
size_t max_caps() const override { return Capability_space::max_caps(); }
void wait_for_exit() override;
void wait_for_exit(int const &) override;
Affinity::Space affinity_space() const override
{

View File

@ -640,7 +640,7 @@ Platform::Platform()
** Generic platform interface **
********************************/
void Platform::wait_for_exit()
void Platform::wait_for_exit(int const &)
{
/*
* On Pistachio, core never exits. So let us sleep forever.

View File

@ -274,7 +274,7 @@ class Genode::Platform : public Platform_generic
Cap_sel asid_pool() const { return _asid_pool_sel; }
void wait_for_exit() override;
void wait_for_exit(int const &) override;
/**
* Determine size of a core local mapping required for a

View File

@ -661,7 +661,7 @@ void Platform::reset_sel(unsigned sel)
}
void Platform::wait_for_exit()
void Platform::wait_for_exit(int const &)
{
sleep_forever();
}

View File

@ -77,7 +77,12 @@ namespace Genode {
/**
* Wait for exit condition
*/
virtual void wait_for_exit() = 0;
virtual void wait_for_exit(int const &exit_value) = 0;
/**
* Handle exit of child
*/
virtual void child_exit() { };
/**
* Return true if platform supports direct unmap (no mapping db)

View File

@ -119,6 +119,8 @@ class Core_child : public Child_policy
Child _child;
int &_exit_value;
public:
/**
@ -128,14 +130,16 @@ class Core_child : public Child_policy
Pd_session &core_pd, Capability<Pd_session> core_pd_cap,
Cpu_session &core_cpu, Capability<Cpu_session> core_cpu_cap,
Cap_quota cap_quota, Ram_quota ram_quota,
Rpc_entrypoint &ep)
Rpc_entrypoint &ep,
int &exit_value)
:
_services(services),
_core_pd_cap (core_pd_cap), _core_pd (core_pd),
_core_cpu_cap(core_cpu_cap), _core_cpu(core_cpu),
_cap_quota(Child::effective_quota(cap_quota)),
_ram_quota(Child::effective_quota(ram_quota)),
_child(local_rm, ep, *this)
_child(local_rm, ep, *this),
_exit_value(exit_value)
{ }
@ -174,6 +178,13 @@ class Core_child : public Child_policy
_core_cpu.transfer_quota(cap, Cpu_session::quota_lim_upscale(100, 100));
}
void exit(int exit_value) override
{
_exit_value = exit_value;
Child_policy::exit(exit_value);
platform().child_exit();
}
Pd_session &ref_pd() override { return _core_pd; }
Pd_session_capability ref_pd_cap() const override { return _core_pd_cap; }
@ -221,6 +232,8 @@ namespace Genode {
int main()
{
static int exit_value { 0 };
/**
* Disable tracing within core because it is currently not fully implemented.
*/
@ -309,10 +322,10 @@ int main()
static Reconstructible<Core_child>
init(services, local_rm, core_pd, core_pd_cap, core_cpu, core_cpu_cap,
init_cap_quota, init_ram_quota, ep);
init_cap_quota, init_ram_quota, ep, exit_value);
platform().wait_for_exit();
platform().wait_for_exit(exit_value);
init.destruct();
return 0;
return exit_value;
}