* 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
This commit is contained in:
Axel Dörfler 2007-01-29 12:43:21 +00:00
parent a6cba27756
commit af0e9c1cb8

View File

@ -1,19 +1,36 @@
/*
* Copyright 2007, Jérôme Duval. All rights reserved.
* Distributed under the terms of the MIT License.
*
*/
#include <sys/wait.h>
#include <stdio.h>
/**
* 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 <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
/*!
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;
}