diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index 59cb7c151a..1b364fea88 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -2185,6 +2185,7 @@ fork_team(void) ThreadCreationAttributes threadCreationAttributes(NULL, parentThread->name, parentThread->priority, NULL, team->id, thread); threadCreationAttributes.forkArgs = forkArgs; + threadCreationAttributes.flags |= THREAD_CREATION_FLAG_DEFER_SIGNALS; threadID = thread_create_thread(threadCreationAttributes, false); if (threadID < 0) { status = threadID; diff --git a/src/tests/system/libroot/posix/Jamfile b/src/tests/system/libroot/posix/Jamfile index 131972cd21..95537a9f38 100644 --- a/src/tests/system/libroot/posix/Jamfile +++ b/src/tests/system/libroot/posix/Jamfile @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src tests system libroot posix ; +UsePrivateHeaders libroot system ; + # filter warnings about strftime()-formats in locale_test TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH) on [ FGristFiles locale_test.o ] += -Wno-format ; @@ -34,6 +36,7 @@ SimpleTest test_time : test_time.c ; SimpleTest tst-mktime : tst-mktime.c ; SimpleTest truncate : truncate.cpp ; SimpleTest init_rld_after_fork_test : init_rld_after_fork_test.cpp ; +SimpleTest user_thread_fork_test : user_thread_fork_test.cpp ; # XSI tests SimpleTest xsi_msg_queue_test1 : xsi_msg_queue_test1.cpp ; diff --git a/src/tests/system/libroot/posix/user_thread_fork_test.cpp b/src/tests/system/libroot/posix/user_thread_fork_test.cpp new file mode 100644 index 0000000000..980b0976cd --- /dev/null +++ b/src/tests/system/libroot/posix/user_thread_fork_test.cpp @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include + +#include + +#include "user_thread.h" + +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); + } + + struct user_thread *t = get_user_thread(); + printf("defer_signals: %" B_PRId32 "\n", t->defer_signals); + + return 0; +}