diff --git a/kernel/tasks.c b/kernel/tasks.c index 83aec680..8be9ea1d 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -214,29 +214,29 @@ static void NORETURN do_exit(int arg) { kfree((void*) tmp, sizeof(vma_t)); } - - - - for (fd = 0; fd < NR_OPEN; fd++) { - if ((curr_task->fildes_table[fd] != NULL) && (curr_task->fildes_table[fd]->count == 1)) { + if (curr_task->fildes_table[fd] != NULL) { /* * delete a descriptor from the per-process object * reference table. If this is not the last reference to the underlying * object, the object will be ignored. */ if (curr_task->fildes_table[fd]->count == 1) { + // kprintf("CLOSE_FS\n"); /* try to close the file */ - status = close_fs(curr_task->fildes_table[fd]); + // status = close_fs(curr_task->fildes_table[fd]); /* close command failed -> return check = errno */ if (BUILTIN_EXPECT(status < 0, 0)) kprintf("Task %u was not able to close file descriptor %i. close_fs returned %d", curr_task->id, fd, -status); - kfree(curr_task->fildes_table[fd], sizeof(fildes_t)); + // kfree(curr_task->fildes_table[fd], sizeof(fildes_t)); + // curr_task->fildes_table[fd] = NULL; } else { - curr_task->fildes_table[fd]->count--; + // kprintf("DECREASE REF\n"); + // curr_task->fildes_table[fd]->count--; + // curr_task->fildes_table[fd] = NULL; } } - } + } // after closing all file decriptors and cleaning up, the table has to be cleared. if(!curr_task->fildes_table)