#include #include #include #include "SharedMemory.h" #include #define Max_Memory_Size 8000 int memoryAccessKey = 12345; int memID; //Shared-Memory-Segment erstellen oder öffnen – shmget() void sharedMemoryInit() { if((memID = shmget(memoryAccessKey, Max_Memory_Size, IPC_CREAT | IPC_EXCL | 0666)) < 0) { std::cerr << "Shared memory with Key: " << memoryAccessKey << " already exists. Delete by Hand before starting vKFM" << std::endl; exit(0); } else { std::cout << "Shared memory with Key: " << memoryAccessKey << " allocated" << std::endl; } } void deleteSharedMemory(int s) { if (shmctl(memID, IPC_RMID, NULL) < 0 ) { std::cerr << "Failed to remove shared Memory, maybe not existing: try cmd: ipcs " << std::endl; } else { std::cout << "shared Memory deleted" << std::endl; } exit(0); } void deleteSharedMemory(void) { if (shmctl(memID, IPC_RMID, NULL) < 0 ) { std::cerr << "Failed to remove shared Memory, maybe not existing: try cmd: ipcs " << std::endl; } else { std::cout << "shared Memory deleted" << std::endl; } exit(0); }