Browse Source

fuck piazza

tarfeef101 6 years ago
parent
commit
4a78e046da
4 changed files with 14 additions and 12 deletions
  1. BIN
      kern/compile/ASST2/kernel
  2. 1 1
      kern/compile/ASST2/vers.c
  3. 1 1
      kern/compile/ASST2/version
  4. 12 10
      kern/syscall/proc_syscalls.c

BIN
kern/compile/ASST2/kernel


+ 1 - 1
kern/compile/ASST2/vers.c

@@ -1,3 +1,3 @@
 /* This file is automatically generated. Edits will be lost.*/
-const int buildversion = 216;
+const int buildversion = 219;
 const char buildconfig[] = "ASST2";

+ 1 - 1
kern/compile/ASST2/version

@@ -1 +1 @@
-216
+219

+ 12 - 10
kern/syscall/proc_syscalls.c

@@ -20,7 +20,7 @@ void sys__exit(int exitcode)
 {
   struct addrspace * as;
   struct proc * p = curproc;
-  p->exitcode = exitcode;
+  p->exitcode = _MKWAIT_EXIT(exitcode);
   DEBUG(DB_SYSCALL,"Syscall: _exit(%d)\n",exitcode);
   KASSERT(curproc->p_addrspace != NULL);
   
@@ -82,8 +82,7 @@ int sys_getpid(pid_t * retval)
 
 int sys_waitpid(pid_t pid, userptr_t status, int options, pid_t * retval)
 {
-  (void)status;
-  if (options != 0)
+  if (options != 0 || !(void *)(status))
   {
     return(EINVAL);
   }
@@ -92,16 +91,19 @@ int sys_waitpid(pid_t pid, userptr_t status, int options, pid_t * retval)
   struct proc * target = getChild(curproc, pid);
   
   if (!(target)) return ECHILD;
-  if (target->exitcode >= 0)
+  if (!(target->exitcode >= 0))
   {
-    *retval = target->exitcode;
-    return 0;
+    lock_acquire(target->waitlock);
+    cv_wait(target->waiting, target->waitlock);
+    lock_release(target->waitlock);
   }
-  
-  lock_acquire(target->waitlock);
-  cv_wait(target->waiting, target->waitlock);
-  lock_release(target->waitlock);
+  int exitstatus = target->exitcode;
   *retval = target->exitcode;
+  int result = copyout((void *)&exitstatus, status, sizeof(int));
+  if (result)
+  {
+    return result;
+  }
   proc_destroy(target);
   return 0;
 }