Kernel: Add function to enumerate processes in session
This commit is contained in:
parent
e33bf62bba
commit
d634fec8dc
|
@ -47,6 +47,7 @@ namespace Kernel
|
|||
void exit(int status, int signal);
|
||||
|
||||
static void for_each_process(const BAN::Function<BAN::Iteration(Process&)>& callback);
|
||||
static void for_each_process_in_session(pid_t sid, const BAN::Function<BAN::Iteration(Process&)>& callback);
|
||||
|
||||
void add_thread(Thread*);
|
||||
void on_thread_exit(Thread&);
|
||||
|
|
|
@ -36,6 +36,21 @@ namespace Kernel
|
|||
}
|
||||
}
|
||||
|
||||
void Process::for_each_process_in_session(pid_t sid, const BAN::Function<BAN::Iteration(Process&)>& callback)
|
||||
{
|
||||
LockGuard _(s_process_lock);
|
||||
|
||||
for (auto* process : s_processes)
|
||||
{
|
||||
if (process->sid() != sid)
|
||||
continue;
|
||||
auto ret = callback(*process);
|
||||
if (ret == BAN::Iteration::Break)
|
||||
return;
|
||||
ASSERT(ret == BAN::Iteration::Continue);
|
||||
}
|
||||
}
|
||||
|
||||
Process* Process::create_process(const Credentials& credentials, pid_t parent, pid_t sid, pid_t pgrp)
|
||||
{
|
||||
static pid_t s_next_id = 1;
|
||||
|
|
Loading…
Reference in New Issue