WIP shm deletion working on blackfin

This commit is contained in:
2020-07-16 16:00:28 +02:00
parent c67b7aab4d
commit 6136eabee2
3 changed files with 46 additions and 14 deletions

View File

@ -29,6 +29,12 @@ extern int phaseShift;
void error(char *msg) { perror(msg); }
void sigInterruptHandler(int p) {
sharedMemory_detach();
sharedMemory_remove();
exit(-1);
}
int main(int argc, char *argv[]) {
// print version
@ -99,6 +105,17 @@ int main(int argc, char *argv[]) {
// control server
if (isControlServer) {
LOG(logINFOBLUE, ("Control Server [%d]\n", portno));
// Catch signal SIGINT to destroy shm properly
struct sigaction sa;
sa.sa_flags = 0;// no flags
sa.sa_handler = sigInterruptHandler;// handler function
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation
// of handler
if (sigaction(SIGINT, &sa, NULL) == -1) {
LOG(logERROR,("Could not set handler function for SIGINT"));
}
if (sharedMemory_create(portno) == FAIL) {
return -1;
}