signals: retry in case of ignored signal

This commit is contained in:
Matheus
2024-05-22 10:44:00 -03:00
parent bab8427275
commit e965ae3ec4
3 changed files with 10 additions and 4 deletions
+1 -1
View File
@@ -152,6 +152,6 @@ void signal_changemask(struct thread_t *thread, int how, sigset_t *new, sigset_t
void signal_signalproc(struct proc_t *proc, int signal);
void signal_signalthread(struct thread_t *thread, int signal, bool urgent);
void signal_pending(struct thread_t *, sigset_t *sigset);
void signal_check(struct thread_t *thread, context_t *context, bool syscall, uint64_t syscallret, uint64_t syscallerrno);
bool signal_check(struct thread_t *thread, context_t *context, bool syscall, uint64_t syscallret, uint64_t syscallerrno);
#endif
+1 -1
View File
@@ -382,7 +382,7 @@ __attribute__((no_caller_saved_registers)) void sched_userspacecheck(context_t *
sched_threadexit();
}
signal_check(thread, context, syscall, syscallret, syscallerrno);
while (signal_check(thread, context, syscall, syscallret, syscallerrno)) ;
}
void sched_stopotherthreads() {
+8 -2
View File
@@ -195,8 +195,9 @@ void signal_signalproc(struct proc_t *proc, int signal) {
PROCESS_LEAVE(proc);
}
void signal_check(struct thread_t *thread, context_t *context, bool syscall, uint64_t syscallret, uint64_t syscallerrno) {
// returns true if should retry check
bool signal_check(struct thread_t *thread, context_t *context, bool syscall, uint64_t syscallret, uint64_t syscallerrno) {
bool retry = false;
proc_t *proc = thread->proc;
PROCESS_ENTER(proc);
@@ -249,12 +250,15 @@ void signal_check(struct thread_t *thread, context_t *context, bool syscall, uin
// urgent signals cannot be ignored, if they are the default action will be run
if (action->address == SIG_IGN && sigset != &thread->signals.urgent) {
retry = true;
goto leave;
} else if ((action->address == SIG_DFL && (action->flags & SA_SIGINFO) == 0) || (action->address == SIG_IGN && sigset == &thread->signals.urgent)) {
// default action
int defaction = defaultactions[signal];
switch (defaction) {
case ACTION_IGN:
case ACTION_CONT:
retry = true;
goto leave;
case ACTION_CORE:
case ACTION_TERM:
@@ -263,6 +267,7 @@ void signal_check(struct thread_t *thread, context_t *context, bool syscall, uin
PROCESS_LEAVE(proc);
interrupt_set(true);
sched_threadexit();
case ACTION_STOP:
default:
__assert(!"unsupported signal action");
}
@@ -330,4 +335,5 @@ void signal_check(struct thread_t *thread, context_t *context, bool syscall, uin
leave:
THREAD_LEAVE(thread);
PROCESS_LEAVE(proc);
return retry;
}