From 25258635f78a5eab4ae85dbbcfa3203da940cc3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 15 Sep 2004 15:44:06 +0000 Subject: [PATCH] Implemented waitpid() a bit more; it now calls the _kern_wait_for_child() syscall. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8972 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/sys/wait.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/kernel/libroot/posix/sys/wait.c b/src/kernel/libroot/posix/sys/wait.c index fc07bec221..a29c2ac8fc 100644 --- a/src/kernel/libroot/posix/sys/wait.c +++ b/src/kernel/libroot/posix/sys/wait.c @@ -24,14 +24,30 @@ wait(int *_status) pid_t waitpid(pid_t pid, int *_status, int options) { - fprintf(stderr, "waitpid(pid = %ld, options = %d): NOT IMPLEMENTED\n", pid, options); - return -1; + status_t returnCode; + int32 reason; + + thread_id thread = _kern_wait_for_child(pid, options, &reason, &returnCode); + + if (_status != NULL) { + // ToDo: fill in _status! + } + + if (thread < B_OK) { + errno = thread; + if (thread == B_WOULD_BLOCK && (options & WNOHANG) != 0) + return 0; + return -1; + } + + return thread; } int waitid(idtype_t idType, id_t id, siginfo_t *info, int options) { + // waitid() is not available on BeOS so we may be lazy here and remove it... fprintf(stderr, "waitid(): NOT IMPLEMENTED\n"); return -1; }