diff --git a/src/tests/system/libroot/posix/Jamfile b/src/tests/system/libroot/posix/Jamfile index 01aae3abc7..4fc453e9bd 100644 --- a/src/tests/system/libroot/posix/Jamfile +++ b/src/tests/system/libroot/posix/Jamfile @@ -4,19 +4,23 @@ UsePrivateHeaders syslog_daemon ; SimpleTest SyslogTest : SyslogTest.cpp syslog.cpp - ; +; SimpleTest flock_test : flock_test.cpp - ; +; SimpleTest setjmp_test : setjmp_test.c - ; +; 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 diff --git a/src/tests/system/libroot/posix/init_rld_after_fork_test.cpp b/src/tests/system/libroot/posix/init_rld_after_fork_test.cpp new file mode 100644 index 0000000000..9ddf947235 --- /dev/null +++ b/src/tests/system/libroot/posix/init_rld_after_fork_test.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include + +#include + + +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; +} \ No newline at end of file