diff options
author | hp.com!davidm <hp.com!davidm> | 2005-05-03 09:13:17 +0000 |
---|---|---|
committer | hp.com!davidm <hp.com!davidm> | 2005-05-03 09:13:17 +0000 |
commit | c0e81195b7e1fc1db66b4c324ba0d356ef7a0032 (patch) | |
tree | 6b92149a4daac224aa6d0c6b2e689d3bdc7305af /tests/Gtest-concurrent.c | |
parent | e8b25005e7a7ff0f67a2fb8b97b16a86dc572dde (diff) | |
download | libunwind-c0e81195b7e1fc1db66b4c324ba0d356ef7a0032.tar.gz |
(doit): Fail gracefully if we fail to create all NTHREADS threads.
(Logical change 1.290)
Diffstat (limited to 'tests/Gtest-concurrent.c')
-rw-r--r-- | tests/Gtest-concurrent.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/Gtest-concurrent.c b/tests/Gtest-concurrent.c index 638ad342..8fe2ef30 100644 --- a/tests/Gtest-concurrent.c +++ b/tests/Gtest-concurrent.c @@ -1,5 +1,5 @@ /* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co + Copyright (C) 2003-2005 Hewlett-Packard Co Contributed by David Mosberger-Tang <davidm@hpl.hp.com> Permission is hereby granted, free of charge, to any person obtaining @@ -84,7 +84,13 @@ doit (void) int i; for (i = 0; i < NTHREADS; ++i) - pthread_create (th + i, NULL, worker, NULL); + if (pthread_create (th + i, NULL, worker, NULL)) + { + fprintf (stderr, "FAILURE: Failed to create %u threads " + "(after %u threads)\n", + NTHREADS, i); + exit (-1); + } for (i = 0; i < NTHREADS; ++i) pthread_join (th[i], NULL); @@ -110,7 +116,10 @@ main (int argc, char **argv) unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_PER_THREAD); if (nerrors) - fprintf (stderr, "FAILURE: detected %d errors\n", nerrors); + { + fprintf (stderr, "FAILURE: detected %d errors\n", nerrors); + exit (-1); + } if (verbose) printf ("SUCCESS\n"); |