about summary refs log tree commit diff
path: root/rt/tst-shm-cancel.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-10-15 10:59:04 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-10-15 13:51:15 -0700
commit9030377480effce89f382499ff47a22467112436 (patch)
tree79cb870b23ce65572fceb699e9acd65db36fda7c /rt/tst-shm-cancel.c
parent602da9de696099f543ee2bb3c1520bc178f42fc9 (diff)
downloadglibc-9030377480effce89f382499ff47a22467112436.tar.gz
glibc-9030377480effce89f382499ff47a22467112436.tar.xz
glibc-9030377480effce89f382499ff47a22467112436.zip
shm tests: Append PID to names passed to shm_open [BZ #26737]
Append PID to names passed to shm_open in shm tests to avoid random

FAIL: rt/tst-shm-cancel
FAIL: rt/tst-shm

due to the same name passed to shm_open and shm_unlink when more than
one "make check" running in parallel on the same machine.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'rt/tst-shm-cancel.c')
-rw-r--r--rt/tst-shm-cancel.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/rt/tst-shm-cancel.c b/rt/tst-shm-cancel.c
index e787229ab2..67d8ce86d5 100644
--- a/rt/tst-shm-cancel.c
+++ b/rt/tst-shm-cancel.c
@@ -26,7 +26,14 @@
 #include <stdlib.h>
 
 static sem_t sem;	/* Use to sync with thread start.  */
-static const char shm_name[] = "/glibc-shm_open-cancel";
+static char shm_name[sizeof "/glibc-shm_open-cancel-" + sizeof (pid_t) * 3];
+
+static void
+init_shm_name (void)
+{
+  snprintf (shm_name, sizeof (shm_name), "/glibc-shm_open-cancel-%u",
+	    getpid ());
+}
 
 static void
 remove_shm (int status, void *arg)
@@ -86,6 +93,8 @@ do_test (void)
 {
   pthread_t td;
 
+  init_shm_name ();
+
   if (sem_init (&sem, 0, 0))
     {
       printf ("error: sem_init failed: %m\n");