diff --git a/src/internal.cpp b/src/internal.cpp index 2fefc58..e44032c 100644 --- a/src/internal.cpp +++ b/src/internal.cpp @@ -1,11 +1,13 @@ #include "internal.h" #include +#include + Impl impl; void *getSharedMemory(){ impl.sharedMemorySize = 8000; - auto id = shmget(impl.sharedMemoryKey, impl.sharedMemorySize, 0644 | IPC_CREAT); + auto id = shmget(impl.sharedMemoryKey, impl.sharedMemorySize, 0644u | IPC_CREAT); if(id == -1){ //error impl.sharedMemorySize = 0; @@ -25,3 +27,11 @@ void *getSharedMemory(){ int getSharedMemorySize(){ return impl.sharedMemorySize; } + +void sendSignal(pid_t pid, int signalNumber) { + kill(pid, signalNumber); +} + +void onSignal(int signalNumber, void(*callback)(int)) { + signal(signalNumber, callback); +} diff --git a/src/internal.h b/src/internal.h index 831ad27..2365c6e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -54,6 +54,19 @@ void *getSharedMemory(); int getSharedMemorySize(); +/** + * send a signal to a process + * @param pid of the process to which the signal is send + * @param signalNumber + */ +void sendSignal(pid_t pid, int signalNumber); + +/** + * calls the callback if a signal is received + * @param signalNumber + */ +void onSignal(int signalNumber, void(*callback)(int)); + /** * set layout version. * @param newValue new layout version number.