Skip to content

Commit

Permalink
Core: exit with child
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmry committed Jul 25, 2019
1 parent 1955221 commit b15148c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions repos/base-linux/src/core/include/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ namespace Genode {
size_t max_caps() const override { return 10000; }

void wait_for_exit() override;

void child_exit() override;
};
}

Expand Down
2 changes: 2 additions & 0 deletions repos/base-linux/src/core/platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ void Platform::wait_for_exit()
lx_exit_group(0);
}

void Platform::child_exit() { sigint_handler(0); }


/*****************************
** Support for IPC library **
Expand Down
5 changes: 5 additions & 0 deletions repos/base/src/core/include/platform_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ namespace Genode {
*/
virtual void wait_for_exit() = 0;

/**
* Handle exit of child
*/
virtual void child_exit() { };

/**
* Return true if platform supports direct unmap (no mapping db)
*/
Expand Down
21 changes: 17 additions & 4 deletions repos/base/src/core/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class Core_child : public Child_policy

Child _child;

int &_exit_value;

public:

/**
Expand All @@ -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)
{ }


Expand Down Expand Up @@ -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; }

Expand Down Expand Up @@ -221,6 +232,8 @@ namespace Genode {

int main()
{
int exit_value = 0;

/**
* Disable tracing within core because it is currently not fully implemented.
*/
Expand Down Expand Up @@ -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();

init.destruct();
return 0;
return exit_value;
}

0 comments on commit b15148c

Please sign in to comment.