Implement signals, finally! #30

Merged
apio merged 14 commits from finally-signals into main 2023-07-10 20:16:00 +00:00
Showing only changes of commit fc3fdc2b87 - Show all commits

View File

@ -98,6 +98,16 @@ Result<SharedPtr<VFS::Inode>> Thread::resolve_atfile(int dirfd, const String& pa
unreachable();
}
enum class DefaultSignalAction
{
Ignore,
Terminate,
};
static constexpr DefaultSignalAction default_actions[] = {
DefaultSignalAction::Terminate // SIGABRT
};
void Thread::process_pending_signals(Registers* current_regs)
{
for (int i = 0; i < NSIG; i++)
@ -123,9 +133,15 @@ void Thread::process_pending_signals(Registers* current_regs)
return;
}
kinfoln("signal: using default behavior (handler=SIG_DFL) (terminating)");
// FIXME: Add different default handlers for different signals and add signal exit codes.
exit_and_signal_parent(255);
kinfoln("signal: using default behavior (handler=SIG_DFL)");
auto action = default_actions[i];
switch (action)
{
case DefaultSignalAction::Ignore: return;
// FIXME: Add signal exit codes.
case DefaultSignalAction::Terminate: exit_and_signal_parent(255);
}
}
// If we fail to deliver the signal (usually because there's not enough space on the stack), execute the
// default action.