Fix a task 0 exit bug
This commit is contained in:
parent
ea961ea0e3
commit
aa73f6fc6e
@ -319,6 +319,55 @@ char *canonicalize_path(char *cwd, char *input) {
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* get_mount_point
|
||||
*
|
||||
*/
|
||||
fs_node_t *get_mount_point(char * path, size_t path_depth) {
|
||||
size_t depth;
|
||||
|
||||
#if 0
|
||||
tree_node_t * tnode = from;
|
||||
foreach(node, tnode->children) {
|
||||
tree_node_t * _node = (tree_node_t *)node->value;
|
||||
shm_node_t * snode = (shm_node_t *)_node->value;
|
||||
|
||||
if (!strcmp(snode->name, pch)) {
|
||||
if (*save == '\0') {
|
||||
return snode;
|
||||
}
|
||||
return _get_node(save, create, _node);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
for (depth = 0; depth < path_depth; ++depth) {
|
||||
/* Search the active directory for the requested directory */
|
||||
node_next = finddir_fs(node_ptr, path_offset);
|
||||
free(node_ptr);
|
||||
node_ptr = node_next;
|
||||
if (!node_ptr) {
|
||||
/* We failed to find the requested directory */
|
||||
/* XXX: This is where we should be checking other file system mappings */
|
||||
free((void *)path);
|
||||
return NULL;
|
||||
} else if (depth == path_depth - 1) {
|
||||
/* We found the file and are done, open the node */
|
||||
open_fs(node_ptr, 1, 0);
|
||||
free((void *)path);
|
||||
return node_ptr;
|
||||
}
|
||||
/* We are still searching... */
|
||||
path_offset += strlen(path_offset) + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return fs_root;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* kopen: Open a file by name.
|
||||
*
|
||||
@ -379,12 +428,13 @@ fs_node_t *kopen(char *filename, uint32_t flags) {
|
||||
|
||||
/*
|
||||
* Dig through the (real) tree to find the file
|
||||
* XXX: Integrate VFS tree!
|
||||
*/
|
||||
uint32_t depth;
|
||||
fs_node_t *node_ptr = malloc(sizeof(fs_node_t));
|
||||
/* Set the active directory to the root */
|
||||
memcpy(node_ptr, fs_root, sizeof(fs_node_t));
|
||||
/* Find the mountpoint for this file */
|
||||
fs_node_t *mount_point = get_mount_point(path, path_depth);
|
||||
/* Set the active directory to the mountpoint */
|
||||
memcpy(node_ptr, mount_point, sizeof(fs_node_t));
|
||||
fs_node_t *node_next = NULL;
|
||||
for (depth = 0; depth < path_depth; ++depth) {
|
||||
/* Search the active directory for the requested directory */
|
||||
@ -393,7 +443,6 @@ fs_node_t *kopen(char *filename, uint32_t flags) {
|
||||
node_ptr = node_next;
|
||||
if (!node_ptr) {
|
||||
/* We failed to find the requested directory */
|
||||
/* XXX: This is where we should be checking other file system mappings */
|
||||
free((void *)path);
|
||||
return NULL;
|
||||
} else if (depth == path_depth - 1) {
|
||||
|
@ -310,7 +310,7 @@ page_fault(
|
||||
return_from_signal_handler();
|
||||
}
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
int present = !(r->err_code & 0x1);
|
||||
int rw = r->err_code & 0x2;
|
||||
int user = r->err_code & 0x4;
|
||||
@ -324,7 +324,7 @@ page_fault(
|
||||
signal_t * sig = malloc(sizeof(signal_t));
|
||||
sig->handler = current_process->signals.functions[SIGSEGV];
|
||||
sig->signum = SIGSEGV;
|
||||
handle_signal(current_process, sig);
|
||||
handle_signal((process_t *)current_process, sig);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <signal.h>
|
||||
|
||||
void enter_signal_handler(uintptr_t location, int signum, uintptr_t stack) {
|
||||
IRQ_OFF;
|
||||
kprintf("[debug] Jumping to 0x%x with %d pushed and a stack at 0x%x\n", location, signum, stack);
|
||||
asm volatile(
|
||||
"mov %2, %%esp\n"
|
||||
@ -37,7 +38,7 @@ void handle_signal(process_t * proc, signal_t * sig) {
|
||||
if (!sig->handler) {
|
||||
kprintf("[debug] Process %d killed by unhandled signal.\n", proc->id);
|
||||
kprintf("Current process = %d\n", current_process->id);
|
||||
kexit(127 + sig->signum);
|
||||
kexit(128 + sig->signum);
|
||||
kprintf("Still here.\n");
|
||||
return;
|
||||
}
|
||||
|
@ -441,6 +441,11 @@ enter_user_jmp(uintptr_t location, int argc, char ** argv, uintptr_t stack) {
|
||||
*/
|
||||
void task_exit(int retval) {
|
||||
/* Free the image memory */
|
||||
if (__builtin_expect(current_process->id == 0,0)) {
|
||||
/* This is probably bad... */
|
||||
switch_next();
|
||||
return;
|
||||
}
|
||||
current_process->status = retval;
|
||||
current_process->finished = 1;
|
||||
wakeup_queue(current_process->wait_queue);
|
||||
|
Loading…
Reference in New Issue
Block a user