Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jleong/change exit behavior #114

Merged
merged 12 commits into from
Feb 22, 2017
Prev Previous commit
Next Next commit
Close file with fd always
  • Loading branch information
omegaphoenix committed Feb 20, 2017
commit 93018227384d5e4730175db3fa2b76fb13105cb3
1 change: 1 addition & 0 deletions src/threads/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ void close_fd(struct thread *cur, int fd) {
struct sys_file *cur_file = list_entry(e, struct sys_file, file_elem);
if (cur_file->fd == fd) {
list_remove(&cur_file->file_elem);
file_close(cur_file->file);
palloc_free_page(cur_file);
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/userprog/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ void process_exit(void) {
if (cur->executable != NULL) {
file_close(cur->executable);
}
cur->executable = NULL;

/* Let parent know it is done. */
sema_up(&cur->wait_sema);
Expand Down
1 change: 0 additions & 1 deletion src/userprog/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ void sys_close(int fd) {
acquire_file_lock();
/* Delete file from thread */
close_fd(cur, fd);
file_close(open_file);
release_file_lock();
}

Expand Down