Missed this one: Completed waitpid().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22089 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
24bcf55926
commit
a7ba350ff2
@ -28,22 +28,34 @@ waitpid(pid_t pid, int *_status, int options)
|
||||
status_t returnCode;
|
||||
int32 reason;
|
||||
|
||||
// TODO: there is no support for WUNTRACED and WCONTINUED yet!
|
||||
thread_id thread = _kern_wait_for_child(pid, options, &reason, &returnCode);
|
||||
|
||||
if (thread >= B_OK && _status != NULL) {
|
||||
int status = returnCode & 0xff;
|
||||
// WEXITSTATUS()
|
||||
|
||||
// See kernel's wait_for_child() for how the return information is encoded:
|
||||
// See kernel's wait_for_child() for how the return information is
|
||||
// encoded:
|
||||
// reason = (signal << 16) | reason
|
||||
|
||||
int status;
|
||||
switch (reason & 0xffff) {
|
||||
case THREAD_RETURN_INTERRUPTED:
|
||||
// fill in signal for WIFSIGNALED() and WTERMSIG()
|
||||
if (reason & THREAD_RETURN_INTERRUPTED)
|
||||
status = (reason >> 8) & 0xff00;
|
||||
|
||||
// TODO: fill in _status correctly for WIFSTOPPED(), WSTOPSIG(), WIFCORED(),
|
||||
// and WIFCONTINUED()
|
||||
break;
|
||||
case THREAD_STOPPED:
|
||||
// WIFSTOPPED() and WSTOPSIG()
|
||||
status = reason & 0xff0000;
|
||||
break;
|
||||
case THREAD_CONTINUED:
|
||||
// WIFCONTINUED()
|
||||
status = 0x20000;
|
||||
break;
|
||||
case THREAD_RETURN_EXIT:
|
||||
default:
|
||||
// WEXITSTATUS()
|
||||
status = returnCode & 0xff;
|
||||
break;
|
||||
}
|
||||
|
||||
*_status = status;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user