X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffunctional%2Fpthread_cancel-points.c;h=8b169a0e247c79076bf3a3c31dea2d59bd575486;hb=6c9a64c370c3fd92b1cda3ef4246933956575c12;hp=2c12ed6ac0d70af3ed6d316631aa2e8194a549b1;hpb=1cc8c424df17d0b0522615f90717d73e86780a44;p=libc-test diff --git a/src/functional/pthread_cancel-points.c b/src/functional/pthread_cancel-points.c index 2c12ed6..8b169a0 100644 --- a/src/functional/pthread_cancel-points.c +++ b/src/functional/pthread_cancel-points.c @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include "test.h" #define TESTC(c, m) ( (c) || (t_error(#c " failed (%s, " m ")\n", cdescr), 0) ) @@ -25,7 +27,6 @@ static void prepare_sem(void *arg) static void cleanup_sem(void *arg) { - TESTR(sem_post(&sem_test), "posting semaphore"); TESTR(sem_destroy(&sem_test), "destroying semaphore"); } @@ -59,11 +60,12 @@ static void prepare_thread(void *arg) static void cleanup_thread(void *arg) { void *res; + if (td_test) { + TESTR(sem_post(&sem_test), "posting semaphore"); + TESTR(pthread_join(td_test, &res), "joining auxiliary thread"); + TESTC(res == 0, "auxiliary thread exit status"); + } cleanup_sem(arg); - if (!td_test) - return; - TESTR(pthread_join(td_test, &res), "joining auxiliary thread"); - TESTC(res == 0, "auxiliary thread exit status"); } static void execute_thread_join(void *arg) @@ -85,8 +87,10 @@ static void execute_shm_open(void *arg) static void cleanup_shm(void *arg) { int *fd = arg; - TESTE(close(*fd), "shm fd"); - TESTE(shm_unlink("/testshm"), ""); + if (*fd > 0) { + TESTE(close(*fd), "shm fd"); + TESTE(shm_unlink("/testshm"), ""); + } } static struct {