Remove shared mem on error

This commit is contained in:
2020-12-28 13:37:30 +01:00
parent 609fd34ab7
commit 8a640acd24

View File

@ -39,6 +39,7 @@ int cache_process() {
void *shm_rw = shmat(shm_id, NULL, 0); void *shm_rw = shmat(shm_id, NULL, 0);
if (shm_rw == (void *) -1) { if (shm_rw == (void *) -1) {
fprintf(stderr, ERR_STR "Unable to attach shared memory (rw): %s" CLR_STR "\n", strerror(errno)); fprintf(stderr, ERR_STR "Unable to attach shared memory (rw): %s" CLR_STR "\n", strerror(errno));
shmctl(shm_id, IPC_RMID, NULL);
return -2; return -2;
} }
cache = shm_rw; cache = shm_rw;