소스 검색

Kernel: The waitpid() syscall was not storing to "wstatus" in all cases

Andreas Kling 5 년 전
부모
커밋
cd42ccd686
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      Kernel/Process.cpp

+ 4 - 3
Kernel/Process.cpp

@@ -1981,7 +1981,7 @@ pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options)
     if (wstatus && !validate_write_typed(wstatus))
     if (wstatus && !validate_write_typed(wstatus))
         return -EFAULT;
         return -EFAULT;
 
 
-    int exit_status;
+    int exit_status = 0;
 
 
     {
     {
         InterruptDisabler disabler;
         InterruptDisabler disabler;
@@ -2001,8 +2001,6 @@ pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options)
                 }
                 }
                 return IterationDecision::Continue;
                 return IterationDecision::Continue;
             });
             });
-            if (wstatus)
-                copy_to_user(wstatus, &exit_status, sizeof(exit_status));
             return reaped_pid;
             return reaped_pid;
         } else {
         } else {
             ASSERT(waitee > 0); // FIXME: Implement other PID specs.
             ASSERT(waitee > 0); // FIXME: Implement other PID specs.
@@ -2036,6 +2034,9 @@ pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options)
         ASSERT(waitee_process->any_thread().state() == Thread::State::Stopped);
         ASSERT(waitee_process->any_thread().state() == Thread::State::Stopped);
         exit_status = 0x7f;
         exit_status = 0x7f;
     }
     }
+
+    if (wstatus)
+        copy_to_user(wstatus, &exit_status, sizeof(exit_status));
     return waitee_pid;
     return waitee_pid;
 }
 }