12#ifndef SST_CORE_INTERPROCESS_TUNNEL_SHM_CHILD_H
13#define SST_CORE_INTERPROCESS_TUNNEL_SHM_CHILD_H
15#include "sst/core/interprocess/tunneldef.h"
29namespace Interprocess {
36template <
typename TunnelType>
46 SHMChild(
const std::string& region_name) : shmPtr(nullptr), fd(-1)
48 fd = shm_open(region_name.c_str(), O_RDWR, S_IRUSR | S_IWUSR);
49 filename = region_name;
53 fprintf(stderr,
"Failed to open IPC region '%s': %s\n", filename.c_str(), strerror(errno));
58 if ( shmPtr == MAP_FAILED ) {
60 fprintf(stderr,
"mmap 0 failed: %s\n", strerror(errno));
64 tunnel =
new TunnelType(shmPtr);
65 shmSize = tunnel->getTunnelSize();
69 shmPtr = mmap(
nullptr, shmSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
70 if ( shmPtr == MAP_FAILED ) {
72 fprintf(stderr,
"mmap 1 failed: %s\n", strerror(errno));
75 uint32_t childnum = tunnel->initialize(shmPtr);
76 if ( childnum == 0 ) { shm_unlink(filename.c_str()); }
84 munmap(shmPtr, shmSize);
104 std::string filename;
Class supports an IPC tunnel between two or more processes, via posix shared memory This class attach...
Definition: shmchild.h:38
TunnelType * getTunnel()
return a pointer to the tunnel
Definition: shmchild.h:95
const std::string & getRegionName(void) const
return the name of the shared memory region
Definition: shmchild.h:98
SHMChild(const std::string ®ion_name)
Child-side tunnel manager for an IPC tunnel Accesses an existing Tunnel using shared memory.
Definition: shmchild.h:46
virtual ~SHMChild()
Destructor.
Definition: shmchild.h:80
Definition: tunneldef.h:37