* 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:
@@ -1,19 +1,36 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007, Jérôme Duval. All rights reserved.
|
* Copyright 2007, Jérôme Duval. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* 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.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int main() {
|
|
||||||
int child_status;
|
#include <errno.h>
|
||||||
pid_t pid = wait(&child_status);
|
#include <stdio.h>
|
||||||
printf("wait returned %ld\n", pid);
|
#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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user