repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / tests / system / libroot / posix / init_rld_after_fork_test.cpp
blob9ddf947235d4b158bc2e43c9abafc87970ca0e41
1 #include <errno.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <unistd.h>
7 #include <OS.h>
10 static void
11 list_semaphores(const char* process)
13 printf("%s (%ld) semaphores:\n", process, find_thread(NULL));
15 sem_info semInfo;
16 int32 cookie = 0;
17 while (get_next_sem_info(B_CURRENT_TEAM, &cookie, &semInfo) == B_OK)
18 printf(" %9ld %s\n", semInfo.sem, semInfo.name);
22 int
23 main()
25 pid_t child = fork();
26 if (child < 0) {
27 fprintf(stderr, "Error: fork() failed: %s\n", strerror(errno));
28 exit(1);
31 if (child > 0) {
32 // the parent process -- wait for the child to finish
33 status_t result;
34 wait_for_thread(child, &result);
37 list_semaphores(child == 0 ? "child" : "parent");
39 return 0;