12 #ifndef SST_CORE_INTERPROCESS_TUNNEL_SHM_CHILD_H
13 #define SST_CORE_INTERPROCESS_TUNNEL_SHM_CHILD_H 1
26 #include "sst/core/interprocess/tunneldef.h"
30 namespace Interprocess {
37 template<
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",
54 filename.c_str(), strerror(errno));
59 if ( shmPtr == MAP_FAILED ) {
61 fprintf(stderr,
"mmap 0 failed: %s\n", strerror(errno));
65 tunnel =
new TunnelType(shmPtr);
66 shmSize = tunnel->getTunnelSize();
70 shmPtr = mmap(
nullptr, shmSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
71 if ( shmPtr == MAP_FAILED ) {
73 fprintf(stderr,
"mmap 1 failed: %s\n", strerror(errno));
76 uint32_t childnum = tunnel->initialize(shmPtr);
78 shm_unlink(filename.c_str());
88 munmap(shmPtr, shmSize);
108 std::string filename;
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:84
TunnelType * getTunnel()
return a pointer to the tunnel
Definition: shmchild.h:99
Class supports an IPC tunnel between two or more processes, via posix shared memory This class attach...
Definition: shmchild.h:38
Definition: tunneldef.h:37
const std::string & getRegionName(void) const
return the name of the shared memory region
Definition: shmchild.h:102