Shared mem debug

This commit is contained in:
2020-12-28 13:48:37 +01:00
parent 8a640acd24
commit b64828b01a

View File

@ -35,11 +35,20 @@ int cache_process() {
fprintf(stderr, ERR_STR "Unable to create shared memory: %s" CLR_STR "\n", strerror(errno));
return -1;
}
struct shmid_ds info;
if (shmctl(shm_id, IPC_STAT, &info) < 0) goto shmctl_err;
info.shm_perm.mode = 0600;
if (shmctl(shm_id, IPC_SET, &info) < 0) {
shmctl_err:
fprintf(stderr, ERR_STR "Unable to update permissions for shared memory: %s" CLR_STR "\n", strerror(errno));
return -3;
}
shmdt(cache);
void *shm_rw = shmat(shm_id, NULL, 0);
if (shm_rw == (void *) -1) {
fprintf(stderr, ERR_STR "Unable to attach shared memory (rw): %s" CLR_STR "\n", strerror(errno));
shmctl(shm_id, IPC_RMID, NULL);
return -2;
}
cache = shm_rw;