summary refs log tree commit diff
diff options
context:
space:
mode:
authorTorvald Riegel <triegel@redhat.com>2014-07-29 21:44:58 +0200
committerTorvald Riegel <triegel@redhat.com>2014-12-15 22:14:33 +0100
commit045a6bcdd2d9c5c83f01171775998ef3104eb10f (patch)
tree6eae33048f1eec461b986e58f082c95e35eb7410
parent7f786dc12bd60f0a134e538429fef98350e4c814 (diff)
downloadglibc-045a6bcdd2d9c5c83f01171775998ef3104eb10f.tar.gz
glibc-045a6bcdd2d9c5c83f01171775998ef3104eb10f.tar.xz
glibc-045a6bcdd2d9c5c83f01171775998ef3104eb10f.zip
Fix nptl/tst-sem4: always start with a fresh semaphore.
-rw-r--r--ChangeLog4
-rw-r--r--nptl/tst-sem4.c8
2 files changed, 10 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 07aca34dd0..420ce23040 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2014-12-15  Torvald Riegel  <triegel@redhat.com>
 
+	* nptl/tst-sem4.c (do_test): Start with a fresh semaphore state.
+
+2014-12-15  Torvald Riegel  <triegel@redhat.com>
+
 	* nptl/tst-mutex5.c (do_test): Do not skip tests if elision is enabled.
 
 2014-12-15  Adhemerval Zanella  <Azanella@linux.vnet.ibm.com>
diff --git a/nptl/tst-sem4.c b/nptl/tst-sem4.c
index 72ed97d370..cf9ef2781e 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 we will 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);