From 37dd5fb902e70bf12cbd262ad6ad17de63ac6bb0 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 6 Jul 2018 15:30:06 +0200 Subject: [PATCH] slsDetectorSoftware: sharedmemory, appends environment variable of SLS_SHM_NAME to shm name --- .../sharedMemory/SharedMemory.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/slsDetectorSoftware/sharedMemory/SharedMemory.cpp b/slsDetectorSoftware/sharedMemory/SharedMemory.cpp index ae05404ac..08cc59d7e 100644 --- a/slsDetectorSoftware/sharedMemory/SharedMemory.cpp +++ b/slsDetectorSoftware/sharedMemory/SharedMemory.cpp @@ -11,7 +11,11 @@ #include // fstat #include // shared memory #include +#include "stdlib.h" +#define SHM_MULTI_PREFIX "/slsDetectorPackage_multi_" +#define SHM_SLS_PREFIX "_sls_" +#define SHM_ENV_NAME "SLS_SHM_NAME" SharedMemory::SharedMemory(int multiId, int slsId): fd(-1), @@ -116,11 +120,20 @@ void* SharedMemory::MapSharedMemory(size_t sz) { std::string SharedMemory::ConstructSharedMemoryName(int multiId, int slsId) { + + // using environment path + string sEnvPath = ""; + char* envpath = getenv(SHM_ENV_NAME); + if (envpath != NULL) { + sEnvPath.assign(envpath); + sEnvPath.insert(0,"_"); + } + stringstream ss; if (slsId < 0) - ss << "/slsDetectorPackage_multi_" << multiId; + ss << SHM_MULTI_PREFIX << multiId << sEnvPath; else - ss << "/slsDetectorPackage_multi_" << multiId << "_sls_" << slsId; + ss << SHM_MULTI_PREFIX << multiId << SHM_SLS_PREFIX << slsId << sEnvPath; std::string temp = ss.str(); if (temp.length() > NAME_MAX) {