library/src/vkvm.cpp

29 lines
647 B
C++
Raw Normal View History

#include "vkvm.h"
#include "internal.h"
2019-11-06 13:41:24 +01:00
#include <unistd.h>
#include <csignal>
void initialize(int pid) {
2019-11-04 23:17:15 +01:00
impl.sharedMemoryPid = pid;
impl.sharedMemoryKey = 892348;
impl.sharedMemorySize = 0;
}
2019-11-06 13:41:24 +01:00
bool registerEvent(EventType type, std::function<void()> handler) {
int signum = SIGUSR1 + impl.eventTable.size();
auto ivt = getInterrupTable();
ivt[type].pid = getpid();
ivt[type].signum = signum;
onSignal(signum, [](int sig){
if(sig >= SIGUSR1){
if((sig - SIGUSR1) < impl.eventTable.size()){
impl.eventTable[sig - SIGUSR1]();
}
}
});
return true;
}