* waitpid() now only clobbers _status in case it succeeded.
* improved comments and TODOs. * added note about unimplemented WUNTRACED, and WCONTINUED options git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20011 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
2e27874523
commit
923ce6f922
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -28,16 +28,23 @@ 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 (_status != NULL) {
|
||||
if (thread >= B_OK && _status != NULL) {
|
||||
int status = returnCode & 0xff;
|
||||
// WEXITSTATUS()
|
||||
|
||||
// ToDo: fill in _status correctly!
|
||||
// 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
|
||||
|
||||
// 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()
|
||||
|
||||
*_status = status;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user