Shared mem debug
This commit is contained in:
11
src/cache.c
11
src/cache.c
@ -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;
|
||||
|
Reference in New Issue
Block a user