This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 2/3] Fix nptl/tst-sem4: always start with a fresh semaphore.
- From: Torvald Riegel <triegel at redhat dot com>
- To: GLIBC Devel <libc-alpha at sourceware dot org>
- Date: Fri, 05 Dec 2014 20:03:42 +0100
- Subject: [PATCH 2/3] Fix nptl/tst-sem4: always start with a fresh semaphore.
- Authentication-results: sourceware.org; auth=none
- References: <1417804668 dot 22797 dot 108 dot camel at triegel dot csb>
This just makes sure that if this test fails, new runs of the test will
start from a fresh state.
commit 1ba62510cc2f1459147ec31dda28d45c2ee96abf
Author: Torvald Riegel <triegel@redhat.com>
Date: Tue Jul 29 21:44:58 2014 +0200
Fix nptl/tst-sem4: always start with a fresh semaphore.
diff --git a/nptl/tst-sem4.c b/nptl/tst-sem4.c
index 72ed97d..5e17d03 100644
--- a/nptl/tst-sem4.c
+++ b/nptl/tst-sem4.c
@@ -39,6 +39,12 @@ do_test (void)
pid_t pid;
int val;
+ /* Start with a clean slate and register a clean-up action. No need to
+ act if sem_unlink fails because well catch the same problem during the
+ sem_open below. */
+ sem_unlink ("/glibc-tst-sem4");
+ on_exit (remove_sem, (void *) "/glibc-tst-sem4");
+
s = sem_open ("/glibc-tst-sem4", O_CREAT, 0600, 1);
if (s == SEM_FAILED)
{
@@ -59,8 +65,6 @@ do_test (void)
return 1;
}
- on_exit (remove_sem, (void *) "/glibc-tst-sem4");
-
/* We have the semaphore object. Now try again with O_EXCL, this
should fail. */
s2 = sem_open ("/glibc-tst-sem4", O_CREAT | O_EXCL, 0600, 1);