From: Ralph Boehme Date: Mon, 19 Nov 2018 15:47:33 +0000 (+0100) Subject: tfork/test: ensure all threads start with SIGCHLD unblocked X-Git-Tag: tdb-1.3.17~588 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8e24596d53b41827135fc48d0603173265b41b1;p=thirdparty%2Fsamba.git tfork/test: ensure all threads start with SIGCHLD unblocked Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- diff --git a/lib/util/tests/tfork.c b/lib/util/tests/tfork.c index 3c73355b3f0..a74f7e8d7e2 100644 --- a/lib/util/tests/tfork.c +++ b/lib/util/tests/tfork.c @@ -470,12 +470,29 @@ static bool test_tfork_threads(struct torture_context *tctx) bool ok = true; const int num_threads = 64; pthread_t threads[num_threads]; + sigset_t set; int i; #ifndef HAVE_PTHREAD torture_skip(tctx, "no pthread support\n"); #endif + /* + * Be nasty and taste for the worst case: ensure all threads start with + * SIGCHLD unblocked so we have the most fun with SIGCHLD being + * delivered to a random thread. :) + */ + sigemptyset(&set); + sigaddset(&set, SIGCHLD); +#ifdef HAVE_PTHREAD + ret = pthread_sigmask(SIG_UNBLOCK, &set, NULL); +#else + ret = sigprocmask(SIG_UNBLOCK, &set, NULL); +#endif + if (ret != 0) { + return -1; + } + for (i = 0; i < num_threads; i++) { ret = pthread_create(&threads[i], NULL, tfork_thread, NULL); torture_assert_goto(tctx, ret == 0, ok, done,