mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
Kernel: Add child to scoped process list after last TRY() in posix_spawn
Before this point, creating the child can still fail, so we shouldn't register it yet. Adding the child to the scoped process list now happens immediately before the process is registered by Process::register_new().
This commit is contained in:
1 parent
c56ec46293
commit
38efa2f990
1 file changed
+5
-5
@@ -100,6 +100,11 @@ ErrorOr<FlatPtr> Process::sys$posix_spawn(Userspace<Syscall::SC_posix_spawn_para
|
||||
// A child created via posix_spawn inherits a copy of its parent's signal mask
|
||||
child_first_thread->update_signal_mask(Thread::current()->signal_mask());
|
||||
|
||||
Thread* new_main_thread = nullptr;
|
||||
InterruptsState previous_interrupts_state = InterruptsState::Enabled;
|
||||
TRY(child->exec(move(path), move(arguments), move(environment), new_main_thread, previous_interrupts_state));
|
||||
thread_finalizer_guard.disarm();
|
||||
|
||||
m_scoped_process_list.with([&](auto const& list_ptr) {
|
||||
if (list_ptr) {
|
||||
child->m_scoped_process_list.with([&](auto& child_list_ptr) {
|
||||
@@ -109,11 +114,6 @@ ErrorOr<FlatPtr> Process::sys$posix_spawn(Userspace<Syscall::SC_posix_spawn_para
|
||||
}
|
||||
});
|
||||
|
||||
Thread* new_main_thread = nullptr;
|
||||
InterruptsState previous_interrupts_state = InterruptsState::Enabled;
|
||||
TRY(child->exec(move(path), move(arguments), move(environment), new_main_thread, previous_interrupts_state));
|
||||
thread_finalizer_guard.disarm();
|
||||
|
||||
Process::register_new(*child);
|
||||
|
||||
// NOTE: All user processes have a leaked ref on them. It's balanced by Thread::WaitBlockerSet::finalize().
|
||||
|
||||
Reference in new issue
Block a user