kernel: Add default actions for signals
This commit is contained in:
parent
bdcb690a7a
commit
fc3fdc2b87
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user