mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
signal: add signal_returnmask and other fixes
This commit is contained in:
@@ -529,7 +529,7 @@ static void yield(context_t *context, void *) {
|
||||
|
||||
thread_t *next = runqueuenext(sleeping ? 0x0fffffff : thread->priority);
|
||||
bool gotsignal = false;
|
||||
for (int i = 0; i < NSIG && thread->proc; ++i) {
|
||||
for (int i = 1; i < NSIG && thread->proc; ++i) {
|
||||
void *action = thread->proc->signals.actions[i].address;
|
||||
if (SIGNAL_GET(&thread->signals.urgent, i)) {
|
||||
gotsignal = true;
|
||||
|
||||
@@ -139,13 +139,17 @@ void signal_pending(struct thread_t *thread, sigset_t *sigset) {
|
||||
PROCESS_LEAVE(proc);
|
||||
}
|
||||
|
||||
void signal_returnmask(struct thread_t *thread, sigset_t *sigset) {
|
||||
memcpy(&thread->signals.returnmask, sigset, sizeof(sigset_t));
|
||||
thread->signals.hasreturnmask = true;
|
||||
}
|
||||
|
||||
void signal_suspend(sigset_t *sigset) {
|
||||
thread_t *thread = _cpu()->thread;
|
||||
THREAD_ENTER(thread);
|
||||
|
||||
memcpy(&thread->signals.oldmask, &thread->signals.mask, sizeof(sigset_t));
|
||||
memcpy(&thread->signals.mask, sigset, sizeof(sigset_t));
|
||||
thread->signals.suspending = true;
|
||||
signal_returnmask(thread, sigset);
|
||||
|
||||
THREAD_LEAVE(thread);
|
||||
|
||||
@@ -548,11 +552,11 @@ bool signal_check(struct thread_t *thread, context_t *context, bool syscall, uin
|
||||
memset(&sigframe.oldstack, 0, sizeof(stack_t));
|
||||
}
|
||||
|
||||
if (thread->signals.suspending) {
|
||||
if (thread->signals.hasreturnmask) {
|
||||
// if we were waiting in signal_suspend, push the old mask into the return frame
|
||||
// of the first signal and set it to not act this way the next check
|
||||
memcpy(&sigframe.oldmask, &thread->signals.oldmask, sizeof(sigset_t));
|
||||
thread->signals.suspending = false;
|
||||
memcpy(&sigframe.oldmask, &thread->signals.returnmask, sizeof(sigset_t));
|
||||
thread->signals.hasreturnmask = false;
|
||||
} else {
|
||||
// else, just push the current mask
|
||||
memcpy(&sigframe.oldmask, &thread->signals.mask, sizeof(sigset_t));
|
||||
|
||||
@@ -286,7 +286,7 @@ static syscallret_t execve(context_t *context, char *upath, char *uargv[], char
|
||||
memset(&_cpu()->thread->signals.stack, 0, sizeof(stack_t));
|
||||
|
||||
// execve keeps information about ignored signals
|
||||
for (int i = 0; i < NSIG; ++i) {
|
||||
for (int i = 1; i < NSIG; ++i) {
|
||||
bool ign = proc->signals.actions[i].address == SIG_IGN;
|
||||
memset(&proc->signals.actions[i], 0, sizeof(sigaction_t));
|
||||
if (ign)
|
||||
|
||||
@@ -125,12 +125,10 @@ syscallret_t syscall_ppoll(context_t *context, pollfd_t *fds, size_t nfds, times
|
||||
return ret;
|
||||
|
||||
signal_changemask(_cpu()->thread, SIG_SETMASK, &sigset, &savedset);
|
||||
signal_returnmask(_cpu()->thread, &savedset);
|
||||
}
|
||||
|
||||
syscallret_t ret = syscall_poll(context, fds, nfds, utimeout ? (timeout.s * 1000 + timeout.ns / 1000000) : -1);
|
||||
|
||||
if (usigset)
|
||||
signal_changemask(_cpu()->thread, SIG_SETMASK, &savedset, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user