mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 10:05:10 +00:00
Kernel: Preserve signal mask across fork(2) and execve(2)
A child created via fork(2) inherits a copy of its parent's signal mask; the signal mask is preserved across execve(2).
This commit is contained in:
parent
0301180f88
commit
92a6c91f4e
3 changed files with 5 additions and 2 deletions
|
@ -523,7 +523,7 @@ ErrorOr<void> Process::do_exec(NonnullRefPtr<OpenFileDescription> main_program_d
|
||||||
for (auto& property : m_coredump_properties)
|
for (auto& property : m_coredump_properties)
|
||||||
property = {};
|
property = {};
|
||||||
|
|
||||||
auto current_thread = Thread::current();
|
auto* current_thread = Thread::current();
|
||||||
current_thread->clear_signals();
|
current_thread->clear_signals();
|
||||||
|
|
||||||
clear_futex_queues_on_exec();
|
clear_futex_queues_on_exec();
|
||||||
|
|
|
@ -43,6 +43,9 @@ ErrorOr<FlatPtr> Process::sys$fork(RegisterState& regs)
|
||||||
dbgln_if(FORK_DEBUG, "fork: child={}", child);
|
dbgln_if(FORK_DEBUG, "fork: child={}", child);
|
||||||
child->address_space().set_enforces_syscall_regions(address_space().enforces_syscall_regions());
|
child->address_space().set_enforces_syscall_regions(address_space().enforces_syscall_regions());
|
||||||
|
|
||||||
|
// A child created via fork(2) inherits a copy of its parent's signal mask
|
||||||
|
child_first_thread->update_signal_mask(Thread::current()->signal_mask());
|
||||||
|
|
||||||
#if ARCH(I386)
|
#if ARCH(I386)
|
||||||
auto& child_regs = child_first_thread->m_regs;
|
auto& child_regs = child_first_thread->m_regs;
|
||||||
child_regs.eax = 0; // fork() returns 0 in the child :^)
|
child_regs.eax = 0; // fork() returns 0 in the child :^)
|
||||||
|
|
|
@ -681,7 +681,7 @@ u32 Thread::signal_mask_block(sigset_t signal_set, bool block)
|
||||||
void Thread::clear_signals()
|
void Thread::clear_signals()
|
||||||
{
|
{
|
||||||
SpinlockLocker lock(g_scheduler_lock);
|
SpinlockLocker lock(g_scheduler_lock);
|
||||||
m_signal_mask = 0;
|
// The signal mask is preserved across execve(2).
|
||||||
m_pending_signals = 0;
|
m_pending_signals = 0;
|
||||||
m_have_any_unmasked_pending_signals.store(false, AK::memory_order_release);
|
m_have_any_unmasked_pending_signals.store(false, AK::memory_order_release);
|
||||||
m_signal_action_data.fill({});
|
m_signal_action_data.fill({});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue