1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 16:35:06 +00:00

Kernel: Rename Process::create() => try_create()

This commit is contained in:
Andreas Kling 2021-09-04 20:56:21 +02:00
parent 1814f66c63
commit 5e2e17c38c
3 changed files with 5 additions and 5 deletions

View file

@ -156,7 +156,7 @@ RefPtr<Process> Process::create_user_process(RefPtr<Thread>& first_thread, const
if (!cwd) if (!cwd)
cwd = VirtualFileSystem::the().root_custody(); cwd = VirtualFileSystem::the().root_custody();
auto process = Process::create(first_thread, parts.take_last(), uid, gid, parent_pid, false, move(cwd), nullptr, tty); auto process = Process::try_create(first_thread, parts.take_last(), uid, gid, parent_pid, false, move(cwd), nullptr, tty);
if (!first_thread) if (!first_thread)
return {}; return {};
if (!process->m_fds.try_resize(process->m_fds.max_open())) { if (!process->m_fds.try_resize(process->m_fds.max_open())) {
@ -197,7 +197,7 @@ RefPtr<Process> Process::create_user_process(RefPtr<Thread>& first_thread, const
RefPtr<Process> Process::create_kernel_process(RefPtr<Thread>& first_thread, String&& name, void (*entry)(void*), void* entry_data, u32 affinity, RegisterProcess do_register) RefPtr<Process> Process::create_kernel_process(RefPtr<Thread>& first_thread, String&& name, void (*entry)(void*), void* entry_data, u32 affinity, RegisterProcess do_register)
{ {
auto process = Process::create(first_thread, move(name), UserID(0), GroupID(0), ProcessID(0), true); auto process = Process::try_create(first_thread, move(name), UserID(0), GroupID(0), ProcessID(0), true);
if (!first_thread || !process) if (!first_thread || !process)
return {}; return {};
first_thread->regs().set_ip((FlatPtr)entry); first_thread->regs().set_ip((FlatPtr)entry);
@ -230,7 +230,7 @@ void Process::unprotect_data()
}); });
} }
RefPtr<Process> Process::create(RefPtr<Thread>& first_thread, const String& name, UserID uid, GroupID gid, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd, RefPtr<Custody> executable, TTY* tty, Process* fork_parent) RefPtr<Process> Process::try_create(RefPtr<Thread>& first_thread, const String& name, UserID uid, GroupID gid, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd, RefPtr<Custody> executable, TTY* tty, Process* fork_parent)
{ {
auto space = Memory::AddressSpace::try_create(fork_parent ? &fork_parent->address_space() : nullptr); auto space = Memory::AddressSpace::try_create(fork_parent ? &fork_parent->address_space() : nullptr);
if (!space) if (!space)

View file

@ -519,7 +519,7 @@ private:
bool remove_thread(Thread&); bool remove_thread(Thread&);
Process(const String& name, UserID, GroupID, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd, RefPtr<Custody> executable, TTY* tty); Process(const String& name, UserID, GroupID, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd, RefPtr<Custody> executable, TTY* tty);
static RefPtr<Process> create(RefPtr<Thread>& first_thread, const String& name, UserID, GroupID, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd = nullptr, RefPtr<Custody> executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr); static RefPtr<Process> try_create(RefPtr<Thread>& first_thread, String const& name, UserID, GroupID, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd = nullptr, RefPtr<Custody> executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr);
KResult attach_resources(NonnullOwnPtr<Memory::AddressSpace>&&, RefPtr<Thread>& first_thread, Process* fork_parent); KResult attach_resources(NonnullOwnPtr<Memory::AddressSpace>&&, RefPtr<Thread>& first_thread, Process* fork_parent);
static ProcessID allocate_pid(); static ProcessID allocate_pid();

View file

@ -18,7 +18,7 @@ KResultOr<FlatPtr> Process::sys$fork(RegisterState& regs)
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
REQUIRE_PROMISE(proc); REQUIRE_PROMISE(proc);
RefPtr<Thread> child_first_thread; RefPtr<Thread> child_first_thread;
auto child = Process::create(child_first_thread, m_name, uid(), gid(), pid(), m_is_kernel_process, m_cwd, m_executable, m_tty, this); auto child = Process::try_create(child_first_thread, m_name, uid(), gid(), pid(), m_is_kernel_process, m_cwd, m_executable, m_tty, this);
if (!child || !child_first_thread) if (!child || !child_first_thread)
return ENOMEM; return ENOMEM;
child->m_veil_state = m_veil_state; child->m_veil_state = m_veil_state;