From 9d0766612f353ab561847578da0e69cea19aabfc Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Thu, 7 Nov 2019 12:41:01 +0100 Subject: [PATCH] + getSharedMemory cleanup --- src/internal.cpp | 26 ++------------------------ src/vkvm.cpp | 2 ++ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/internal.cpp b/src/internal.cpp index d4ef7e9..287d561 100644 --- a/src/internal.cpp +++ b/src/internal.cpp @@ -2,32 +2,10 @@ #include #include +#include "SharedMemoryAccess.h" + Impl impl; -void *getSharedMemory(){ - impl.sharedMemorySize = 8000; - - auto id = shmget(impl.sharedMemoryKey, impl.sharedMemorySize, 0644u | IPC_CREAT); - if(id == -1){ - //error - impl.sharedMemorySize = 0; - return nullptr; - } - - void *data = shmat(id, nullptr, 0); - if(data == (char*)(-1)){ - //error - impl.sharedMemorySize = 0; - return nullptr; - } - - return data; -} - -int getSharedMemorySize(){ - return impl.sharedMemorySize; -} - void sendSignal(pid_t pid, int signalNumber) { kill(pid, signalNumber); } diff --git a/src/vkvm.cpp b/src/vkvm.cpp index 27350f4..be44a83 100644 --- a/src/vkvm.cpp +++ b/src/vkvm.cpp @@ -16,6 +16,8 @@ bool registerEvent(EventType type, std::function handler) { ivt[type].pid = getpid(); ivt[type].signum = signum; + impl.eventTable.push_back(handler); + onSignal(signum, [](int sig){ if(sig >= SIGUSR1){ if((sig - SIGUSR1) < impl.eventTable.size()){