From e2b4fa14f9b719e3a7be7d74ba767d945603f561 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sun, 16 Nov 2014 06:59:58 +0000 Subject: [PATCH] Call sem_unlink on semaphores before attempting to create them Due to the lack of uniqueness in the semaphore name, and the fact that the tests don't have cleanup routines, an interrupted test can leave a semaphore "laying around", causing all subsequent attempts to run the test to fail I will file a NetBSD PR for this issue soon --- contrib/netbsd-tests/lib/librt/t_sem.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/netbsd-tests/lib/librt/t_sem.c b/contrib/netbsd-tests/lib/librt/t_sem.c index b6fc4dbf197..e76cd521559 100644 --- a/contrib/netbsd-tests/lib/librt/t_sem.c +++ b/contrib/netbsd-tests/lib/librt/t_sem.c @@ -86,6 +86,9 @@ ATF_TC_BODY(basic, tc) if (sysconf(_SC_SEMAPHORES) == -1) atf_tc_skip("POSIX semaphores not supported"); +#ifdef __FreeBSD__ + sem_unlink("/sem_b"); +#endif sem_b = sem_open("/sem_b", O_CREAT | O_EXCL, 0644, 0); ATF_REQUIRE(sem_b != SEM_FAILED); @@ -127,6 +130,9 @@ ATF_TC_BODY(child, tc) if (sysconf(_SC_SEMAPHORES) == -1) atf_tc_skip("POSIX semaphores not supported"); +#ifdef __FreeBSD__ + sem_unlink("/sem_a"); +#endif sem_a = sem_open("/sem_a", O_CREAT | O_EXCL, 0644, 0); ATF_REQUIRE(sem_a != SEM_FAILED);