diff options
author | Ralph Boehme <slow@samba.org> | 2018-11-19 16:47:33 +0100 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2018-11-28 12:59:27 +0100 |
commit | f8e24596d53b41827135fc48d0603173265b41b1 (patch) | |
tree | 7a1975290b5cdfa698bc1c9830b6007d589bd0a7 /lib | |
parent | fde9f7c81b42419e71b2fc8c31d92db4a05176af (diff) | |
download | samba-f8e24596d53b41827135fc48d0603173265b41b1.tar.gz |
tfork/test: ensure all threads start with SIGCHLD unblocked
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/tests/tfork.c | 17 |
1 files changed, 17 insertions, 0 deletions
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, |