From af0e9c1cb851c792a374f1a19159ce0eb9897a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 29 Jan 2007 12:43:21 +0000 Subject: [PATCH] * Added some calls to waitpid() which should result in the same error code. * Fixed comment, as Haiku now behaves properly at least for most cases :-) * Style guide update. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20007 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/system/kernel/wait_test.c | 45 ++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/tests/system/kernel/wait_test.c b/src/tests/system/kernel/wait_test.c index 38a8ff9858..0631359bab 100644 --- a/src/tests/system/kernel/wait_test.c +++ b/src/tests/system/kernel/wait_test.c @@ -1,19 +1,36 @@ /* -* Copyright 2007, Jérôme Duval. All rights reserved. -* Distributed under the terms of the MIT License. -* -*/ -#include -#include - -/** - * wait() doesn't return on Haiku, whereas it should return an error when the - * process has no children. + * Copyright 2007, Jérôme Duval. All rights reserved. + * Distributed under the terms of the MIT License. */ -int main() { - int child_status; - pid_t pid = wait(&child_status); - printf("wait returned %ld\n", pid); + +#include +#include +#include +#include +#include + + +/*! + wait()/waitpid() should return -1 and set errno to ECHILD, since there + are no children to wait for. +*/ +int +main() +{ + int childStatus; + pid_t pid = wait(&childStatus); + printf("wait() returned %ld (%s)\n", pid, strerror(errno)); + + pid = waitpid(-1, &childStatus, 0); + printf("waitpid(-1, ...) returned %ld (%s)\n", pid, strerror(errno)); + + pid = waitpid(0, &childStatus, 0); + printf("waitpid(0, ...) returned %ld (%s)\n", pid, strerror(errno)); + + pid = waitpid(getpgrp(), &childStatus, 0); + printf("waitpid(%ld, ...) returned %ld (%s)\n", getpgrp(), pid, strerror(errno)); + + return 0; }