1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:47:34 +00:00

Kernel: Make Threads always have a name

We previously allowed Thread to exist in a state where its m_name was
null, and had to work around that in various places.

This patch removes that possibility and forces those who would create a
thread (or change the name of one) to provide a NonnullOwnPtr<KString>
with the name.
This commit is contained in:
Andreas Kling 2021-09-06 12:44:27 +02:00
parent cda2b9e71c
commit 7981422500
7 changed files with 25 additions and 13 deletions

View file

@ -498,6 +498,11 @@ KResult Process::do_exec(NonnullRefPtr<FileDescription> main_program_description
if (parts.is_empty())
return ENOENT;
auto new_process_name = parts.take_last();
auto new_main_thread_name = KString::try_create(new_process_name);
if (!new_main_thread_name)
return ENOMEM;
auto main_program_metadata = main_program_description->metadata();
auto load_result = TRY(load(main_program_description, interpreter_description, main_program_header));
@ -620,8 +625,8 @@ KResult Process::do_exec(NonnullRefPtr<FileDescription> main_program_description
// NOTE: Be careful to not trigger any page faults below!
m_name = parts.take_last();
new_main_thread->set_name(KString::try_create(m_name));
m_name = move(new_process_name);
new_main_thread->set_name(new_main_thread_name.release_nonnull());
{
ProtectedDataMutationScope scope { *this };