mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
signals: retry in case of ignored signal
This commit is contained in:
@@ -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_signalproc(struct proc_t *proc, int signal);
|
||||||
void signal_signalthread(struct thread_t *thread, int signal, bool urgent);
|
void signal_signalthread(struct thread_t *thread, int signal, bool urgent);
|
||||||
void signal_pending(struct thread_t *, sigset_t *sigset);
|
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
|
#endif
|
||||||
|
|||||||
@@ -382,7 +382,7 @@ __attribute__((no_caller_saved_registers)) void sched_userspacecheck(context_t *
|
|||||||
sched_threadexit();
|
sched_threadexit();
|
||||||
}
|
}
|
||||||
|
|
||||||
signal_check(thread, context, syscall, syscallret, syscallerrno);
|
while (signal_check(thread, context, syscall, syscallret, syscallerrno)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sched_stopotherthreads() {
|
void sched_stopotherthreads() {
|
||||||
|
|||||||
@@ -195,8 +195,9 @@ void signal_signalproc(struct proc_t *proc, int signal) {
|
|||||||
PROCESS_LEAVE(proc);
|
PROCESS_LEAVE(proc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns true if should retry check
|
||||||
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) {
|
||||||
|
bool retry = false;
|
||||||
proc_t *proc = thread->proc;
|
proc_t *proc = thread->proc;
|
||||||
|
|
||||||
PROCESS_ENTER(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
|
// urgent signals cannot be ignored, if they are the default action will be run
|
||||||
if (action->address == SIG_IGN && sigset != &thread->signals.urgent) {
|
if (action->address == SIG_IGN && sigset != &thread->signals.urgent) {
|
||||||
|
retry = true;
|
||||||
goto leave;
|
goto leave;
|
||||||
} else if ((action->address == SIG_DFL && (action->flags & SA_SIGINFO) == 0) || (action->address == SIG_IGN && sigset == &thread->signals.urgent)) {
|
} else if ((action->address == SIG_DFL && (action->flags & SA_SIGINFO) == 0) || (action->address == SIG_IGN && sigset == &thread->signals.urgent)) {
|
||||||
// default action
|
// default action
|
||||||
int defaction = defaultactions[signal];
|
int defaction = defaultactions[signal];
|
||||||
switch (defaction) {
|
switch (defaction) {
|
||||||
case ACTION_IGN:
|
case ACTION_IGN:
|
||||||
|
case ACTION_CONT:
|
||||||
|
retry = true;
|
||||||
goto leave;
|
goto leave;
|
||||||
case ACTION_CORE:
|
case ACTION_CORE:
|
||||||
case ACTION_TERM:
|
case ACTION_TERM:
|
||||||
@@ -263,6 +267,7 @@ void signal_check(struct thread_t *thread, context_t *context, bool syscall, uin
|
|||||||
PROCESS_LEAVE(proc);
|
PROCESS_LEAVE(proc);
|
||||||
interrupt_set(true);
|
interrupt_set(true);
|
||||||
sched_threadexit();
|
sched_threadexit();
|
||||||
|
case ACTION_STOP:
|
||||||
default:
|
default:
|
||||||
__assert(!"unsupported signal action");
|
__assert(!"unsupported signal action");
|
||||||
}
|
}
|
||||||
@@ -330,4 +335,5 @@ void signal_check(struct thread_t *thread, context_t *context, bool syscall, uin
|
|||||||
leave:
|
leave:
|
||||||
THREAD_LEAVE(thread);
|
THREAD_LEAVE(thread);
|
||||||
PROCESS_LEAVE(proc);
|
PROCESS_LEAVE(proc);
|
||||||
|
return retry;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user