lx_emul: get pid from task

Issue #4455.
This commit is contained in:
Josef Söntgen 2022-02-18 11:11:09 +01:00 committed by Christian Helmuth
parent 4b43b5c1c1
commit 0c617366e5
2 changed files with 15 additions and 0 deletions

View File

@ -26,6 +26,8 @@ struct task_struct * lx_emul_task_get_current(void);
struct task_struct * lx_emul_task_get(int pid);
int lx_emul_task_pid(struct task_struct *task);
void lx_emul_task_create(struct task_struct * task,
const char * name,
int pid,

View File

@ -70,6 +70,19 @@ extern "C" struct task_struct * lx_emul_task_get(int pid)
}
extern "C" int lx_emul_task_pid(struct task_struct * t)
{
int ret = -1;
Lx_kit::env().scheduler.for_each_task([&] (Lx_kit::Task & task) {
if (t == task.lx_task())
ret = task.pid();
});
return ret;
}
extern "C" void lx_emul_task_name(struct task_struct * t, const char * name)
{
Lx_kit::env().scheduler.task((void*)t).name(name);