Fix handling of signal suicides
This commit is contained in:
parent
4fee088b62
commit
3afb51a951
@ -53,10 +53,7 @@ static uint32_t write_unixpipe(fs_node_t * node, uint32_t offset, uint32_t size,
|
||||
while (written < size) {
|
||||
if (self->read_closed) {
|
||||
/* SIGPIPE to current process */
|
||||
signal_t * sig = malloc(sizeof(signal_t));
|
||||
sig->handler = current_process->signals.functions[SIGPIPE];
|
||||
sig->signum = SIGPIPE;
|
||||
handle_signal((process_t *)current_process, sig);
|
||||
send_signal(getpid(), SIGPIPE);
|
||||
|
||||
return written;
|
||||
}
|
||||
|
@ -204,13 +204,6 @@ uint32_t first_frame(void) {
|
||||
debug_video_crash(msgs);
|
||||
}
|
||||
|
||||
#if 0
|
||||
signal_t * sig = malloc(sizeof(signal_t));
|
||||
sig->handler = current_process->signals.functions[SIGSEGV];
|
||||
sig->signum = SIGSEGV;
|
||||
handle_signal((process_t *)current_process, sig);
|
||||
#endif
|
||||
|
||||
STOP;
|
||||
|
||||
return -1;
|
||||
@ -529,11 +522,7 @@ page_fault(
|
||||
|
||||
#endif
|
||||
|
||||
signal_t * sig = malloc(sizeof(signal_t));
|
||||
sig->handler = current_process->signals.functions[SIGSEGV];
|
||||
sig->signum = SIGSEGV;
|
||||
handle_signal((process_t *)current_process, sig);
|
||||
|
||||
send_signal(current_process->id, SIGSEGV);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -111,7 +111,7 @@ void handle_signal(process_t * proc, signal_t * sig) {
|
||||
return;
|
||||
}
|
||||
|
||||
debug_print(NOTICE, "handling signal in process %d (%d)", proc->id, signum);
|
||||
debug_print(NOTICE, "handling signal in process %d (%d) (0x%x)", proc->id, signum, handler);
|
||||
|
||||
uintptr_t stack = 0xFFFF0000;
|
||||
if (proc->syscall_registers->useresp < 0x10000100) {
|
||||
@ -129,7 +129,7 @@ list_t * rets_from_sig;
|
||||
|
||||
void return_from_signal_handler(void) {
|
||||
#if 0
|
||||
debug_print(INFO, "Return From Signal for process %d", current_process->id);
|
||||
debug_print(ERROR, "Return From Signal for process %d", current_process->id);
|
||||
#endif
|
||||
|
||||
if (__builtin_expect(!rets_from_sig, 0)) {
|
||||
@ -163,9 +163,14 @@ void fix_signal_stacks(void) {
|
||||
p->thread.esp = p->signal_state.esp;
|
||||
p->thread.eip = p->signal_state.eip;
|
||||
p->thread.ebp = p->signal_state.ebp;
|
||||
if (!p->signal_kstack) {
|
||||
debug_print(ERROR, "Cannot restore signal stack for pid=%d - unset?", p->id);
|
||||
} else {
|
||||
debug_print(ERROR, "Restoring signal stack for pid=%d", p->id);
|
||||
memcpy((void *)(p->image.stack - KERNEL_STACK_SIZE), p->signal_kstack, KERNEL_STACK_SIZE);
|
||||
free(p->signal_kstack);
|
||||
p->signal_kstack = NULL;
|
||||
}
|
||||
make_process_ready(p);
|
||||
}
|
||||
spin_unlock(sig_lock_b);
|
||||
@ -215,13 +220,17 @@ int send_signal(pid_t process, uint32_t signal) {
|
||||
if (receiver->node_waits) {
|
||||
process_awaken_from_fswait(receiver, -1);
|
||||
}
|
||||
|
||||
if (!process_is_ready(receiver)) {
|
||||
make_process_ready(receiver);
|
||||
}
|
||||
|
||||
list_insert(receiver->signal_queue, sig);
|
||||
|
||||
if (receiver == current_process) {
|
||||
/* Forces us to be rescheduled and enter signal handler */
|
||||
switch_next();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user