From: Florian Krohm Date: Fri, 12 Aug 2011 15:07:10 +0000 (+0000) Subject: Check return code of pthread_create and bail out if X-Git-Tag: svn/VALGRIND_3_7_0~270 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5800c7271cce9089c9fdd447ca8119687b9c280a;p=thirdparty%2Fvalgrind.git Check return code of pthread_create and bail out if the function failed. This helps on systems which don't have lots of memory. Suggested by Christian Borntraeger. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11967 --- diff --git a/drd/tests/pth_barrier.c b/drd/tests/pth_barrier.c index e0b40a7a13..7bca33a5b6 100644 --- a/drd/tests/pth_barrier.c +++ b/drd/tests/pth_barrier.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include /*********************/ @@ -81,7 +83,11 @@ static void barriers_and_races(const int nthread, const int iterations) t[i].b = &b; t[i].array = array; t[i].iterations = iterations; - pthread_create(&t[i].tid, 0, (void*(*)(void*))threadfunc, &t[i]); + if (pthread_create(&t[i].tid, 0, (void*(*)(void*))threadfunc, &t[i])) { + fprintf(stderr, "Could not create thread #%d (of %d): %s\n", + i, nthread, strerror(errno)); + exit(1); + } } for (i = 0; i < nthread; i++)