Select Git revision
-
a2-stratford authoreda2-stratford authored
syscall_exit.c 574 B
#include "system_calls.h"
#include "threads/interrupt.h" // Dependency for intr_frame struct
#include "threads/thread.h" // Dependency for thread struct
void syscall_exit(struct intr_frame *f) {
struct thread *current_thread; // creates thread struct from thread.h
current_thread = thread_current(); // Sets current thread
// pop off first int argument from interrupt frame
int exit_code = *((int*)f->esp + 1);
current_thread->exit_code = exit_code; // Returns exit code to kernel
thread_exit(); // Exiting current thread
f->eax = -1; // Returning -1 for success
}