mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
Kernel: Use TRY() when creating first thread in a new process
This commit is contained in:
parent
2ab8fd89fc
commit
ae885b188f
1 changed files with 3 additions and 6 deletions
|
@ -263,19 +263,16 @@ KResult Process::attach_resources(NonnullOwnPtr<Memory::AddressSpace>&& prealloc
|
||||||
{
|
{
|
||||||
m_space = move(preallocated_space);
|
m_space = move(preallocated_space);
|
||||||
|
|
||||||
auto thread_or_error = [&] {
|
auto create_first_thread = [&] {
|
||||||
if (fork_parent) {
|
if (fork_parent) {
|
||||||
// NOTE: fork() doesn't clone all threads; the thread that called fork() becomes the only thread in the new process.
|
// NOTE: fork() doesn't clone all threads; the thread that called fork() becomes the only thread in the new process.
|
||||||
return Thread::current()->try_clone(*this);
|
return Thread::current()->try_clone(*this);
|
||||||
}
|
}
|
||||||
// NOTE: This non-forked code path is only taken when the kernel creates a process "manually" (at boot.)
|
// NOTE: This non-forked code path is only taken when the kernel creates a process "manually" (at boot.)
|
||||||
return Thread::try_create(*this);
|
return Thread::try_create(*this);
|
||||||
}();
|
};
|
||||||
|
|
||||||
if (thread_or_error.is_error())
|
first_thread = TRY(create_first_thread());
|
||||||
return thread_or_error.error();
|
|
||||||
|
|
||||||
first_thread = thread_or_error.release_value();
|
|
||||||
|
|
||||||
if (!fork_parent) {
|
if (!fork_parent) {
|
||||||
// FIXME: Figure out if this is really necessary.
|
// FIXME: Figure out if this is really necessary.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue