Test to verify that the runtime loader semaphore is not initialized

after fork().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21885 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2007-08-11 00:07:52 +00:00
parent d65a066a81
commit 6981ec9f0a
2 changed files with 48 additions and 4 deletions

View File

@ -18,6 +18,10 @@ SimpleTest sigsetjmp_test
: sigsetjmp_test.c
;
SimpleTest init_rld_after_fork_test
: init_rld_after_fork_test.cpp
;
# Tell Jam where to find these sources
SEARCH on [ FGristFiles
syslog.cpp

View File

@ -0,0 +1,40 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <OS.h>
static void
list_semaphores(const char* process)
{
printf("%s (%ld) semaphores:\n", process, find_thread(NULL));
sem_info semInfo;
int32 cookie = 0;
while (get_next_sem_info(B_CURRENT_TEAM, &cookie, &semInfo) == B_OK)
printf(" %9ld %s\n", semInfo.sem, semInfo.name);
}
int
main()
{
pid_t child = fork();
if (child < 0) {
fprintf(stderr, "Error: fork() failed: %s\n", strerror(errno));
exit(1);
}
if (child > 0) {
// the parent process -- wait for the child to finish
status_t result;
wait_for_thread(child, &result);
}
list_semaphores(child == 0 ? "child" : "parent");
return 0;
}