From 39018419cde7bf6dc153eeb1f13fbbba935a8acc Mon Sep 17 00:00:00 2001 From: sBubshait Date: Thu, 7 Nov 2024 12:15:29 +0000 Subject: [PATCH] Fix Bug in Process.c to print the exit statement in process_exit instead of exit syscall to handle unexpected/bad exits --- src/userprog/process.c | 2 ++ src/userprog/syscall.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/userprog/process.c b/src/userprog/process.c index 01f30d5..6c8ef2d 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -217,6 +217,8 @@ process_exit (void) struct thread *cur = thread_current (); uint32_t *pd; + printf ("%s: exit(%d)\n", cur->name, cur->exit_status); + /* Destroy the current process's page directory and switch back to the kernel-only page directory. */ pd = cur->pagedir; diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 9991156..1dbe73b 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -105,7 +105,6 @@ syscall_exit (int status) { /* Sets exit_status of the thread to status. thread_exit () will call process_exit () if user programs are allowed. */ - printf ("%s: exit(%d)\n", thread_current()->name, status); thread_current ()->exit_status = status; thread_exit (); }