1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-22 15:47:37 +01:00

(doit): Fail gracefully if we fail to create all NTHREADS threads.

(Logical change 1.290)
This commit is contained in:
hp.com!davidm 2005-05-03 09:13:17 +00:00
parent e8b25005e7
commit c0e81195b7

View file

@ -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");