summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-12-11 17:40:50 +0200
committerIdan Horowitz <idan.horowitz@gmail.com>2021-12-12 08:34:19 +0200
commit81a76a30a15843dacf96abca9b6a119cc6b95440 (patch)
tree2c0df1d787ad8891e117a6eb183a2293945883fa
parent31fa3f8b1b78c28c45d0d8183f6f3652ceb52da8 (diff)
downloadserenity-81a76a30a15843dacf96abca9b6a119cc6b95440.zip
Kernel: Preserve pending signals across execve(2)s
As required by posix. Also rename Thread::clear_signals to Thread::reset_signals_for_exec since it doesn't actually clear any pending signals, but rather does execve related signal book-keeping.
-rw-r--r--Kernel/Syscalls/execve.cpp2
-rw-r--r--Kernel/Thread.cpp4
-rw-r--r--Kernel/Thread.h2
3 files changed, 4 insertions, 4 deletions
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp
index a2bbb92765..eb7946f6fa 100644
--- a/Kernel/Syscalls/execve.cpp
+++ b/Kernel/Syscalls/execve.cpp
@@ -524,7 +524,7 @@ ErrorOr<void> Process::do_exec(NonnullRefPtr<OpenFileDescription> main_program_d
property = {};
auto* current_thread = Thread::current();
- current_thread->clear_signals();
+ current_thread->reset_signals_for_exec();
clear_futex_queues_on_exec();
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index e097849b93..85d087ffce 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -678,11 +678,11 @@ u32 Thread::signal_mask_block(sigset_t signal_set, bool block)
return previous_signal_mask;
}
-void Thread::clear_signals()
+void Thread::reset_signals_for_exec()
{
SpinlockLocker lock(g_scheduler_lock);
// The signal mask is preserved across execve(2).
- m_pending_signals = 0;
+ // The pending signal set is preserved across an execve(2).
m_have_any_unmasked_pending_signals.store(false, AK::memory_order_release);
m_signal_action_data.fill({});
// A successful call to execve(2) removes any existing alternate signal stack
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index 50a5a57032..a225191ca5 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -1010,7 +1010,7 @@ public:
u32 update_signal_mask(u32 signal_mask);
u32 signal_mask_block(sigset_t signal_set, bool block);
u32 signal_mask() const;
- void clear_signals();
+ void reset_signals_for_exec();
ErrorOr<FlatPtr> peek_debug_register(u32 register_index);
ErrorOr<void> poke_debug_register(u32 register_index, FlatPtr data);