Kill task's children when task exits

This commit is contained in:
Andrew Pamment 2021-12-14 22:56:42 +10:00
parent 299e6cbed5
commit 4d42e793b9
6 changed files with 21 additions and 4 deletions

3
gui.c
View File

@ -605,6 +605,7 @@ void gui_raise_to_top(int wh) {
windows[window_count - 1] = win; windows[window_count - 1] = win;
windows[window_count - 1]->zorder = window_count - 1; windows[window_count - 1]->zorder = window_count - 1;
windows[window_count - 1]->focused = 1; windows[window_count - 1]->focused = 1;
keyboard_set_handler(windows[window_count - 1]->keyboard_dest);
} }
void gui_flip() { void gui_flip() {
@ -630,7 +631,6 @@ void gui_flip() {
} else if (mouse_pos_x > windows[i]->posx && mouse_pos_x < windows[i]->posx + 25 && mouse_pos_y > windows[i]->posy - 25 && mouse_pos_y < windows[i]->posy) { } else if (mouse_pos_x > windows[i]->posx && mouse_pos_x < windows[i]->posx + 25 && mouse_pos_y > windows[i]->posy - 25 && mouse_pos_y < windows[i]->posy) {
windows[i]->close_req = 1; windows[i]->close_req = 1;
} else if (windows[i]->focused == 0) { } else if (windows[i]->focused == 0) {
keyboard_set_handler(windows[i]->keyboard_dest);
gui_raise_to_top(i); gui_raise_to_top(i);
} }
break; break;
@ -643,7 +643,6 @@ void gui_flip() {
if (mouse_pos_x > windows[i]->iconx -16 && mouse_pos_x < windows[i]->iconx + 72 && mouse_pos_y > windows[i]->icony -16 && mouse_pos_y < windows[i]->icony + 72) { if (mouse_pos_x > windows[i]->iconx -16 && mouse_pos_x < windows[i]->iconx + 72 && mouse_pos_y > windows[i]->icony -16 && mouse_pos_y < windows[i]->icony + 72) {
windows[i]->minimized = 0; windows[i]->minimized = 0;
gui_raise_to_top(i); gui_raise_to_top(i);
keyboard_set_handler(windows[i]->keyboard_dest);
break; break;
} }
} }

BIN
misc/icons/text.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -16,3 +16,7 @@ WORK=disk0:/
EXEC=disk0:/games/qdoom.exe EXEC=disk0:/games/qdoom.exe
ICON=disk0:/icons/qdoom.png ICON=disk0:/icons/qdoom.png
WORK=disk0:/games/ WORK=disk0:/games/
EXEC=disk0:/text.exe
ICON=disk0:/icons/text.png
WORK=disk0:/

View File

@ -465,6 +465,7 @@ void process_char(char c) {
} }
void exit_callback(int wh) { void exit_callback(int wh) {
quinn_exit(); quinn_exit();
exit(0); exit(0);
} }
@ -510,6 +511,7 @@ int main(int argc, char **argv) {
close(ParentWrite); close(ParentWrite);
execve("disk0:/shell.exe", sargv, environ); execve("disk0:/shell.exe", sargv, environ);
exit(-1);
} else { } else {
close(ChildRead); close(ChildRead);
close(ChildWrite); close(ChildWrite);

View File

@ -133,8 +133,19 @@ void init_scheduler(void) {
void sched_free_task(struct task_t *this_task) { void sched_free_task(struct task_t *this_task) {
int i; int i;
// stop parent task from waiting // kill children
struct task_t *task = first_task;
for (task = first_task; task != (void *)0; task = task->next_task) {
if (task->parent_task == this_task) {
task->timetorun = 0;
task->state = TASK_ZOMBIE;
task->exit_status = 127;
task->zombie_ttl = 5;
}
}
// stop parent task from waiting
// free stuff // free stuff
// free any userpages // free any userpages
// free stack virt space // free stack virt space
@ -183,6 +194,7 @@ void sched_free_task(struct task_t *this_task) {
} }
current_task->next_task = this_task->next_task; current_task->next_task = this_task->next_task;
free(this_task); free(this_task);
} }

2
vfs.c
View File

@ -1022,7 +1022,7 @@ int vfs_open_file_dev(struct vfs_device_t *device, char *path, int flags, int mo
return i; return i;
} else { } else {
if (flags & O_CREAT) { if (flags & O_CREAT) {
if (minix_create_file(device, temppath) == 0) kprintf("Create File Successful\n"); minix_create_file(device, temppath);
info = minix_check_if_exists(device, temppath, -1); info = minix_check_if_exists(device, temppath, -1);
if (info != NULL) { if (info != NULL) {
for (i=0;i<256;i++) { for (i=0;i<256;i++) {