diff --git a/fb_arc_set/shared/shm.c b/fb_arc_set/shared/shm.c index d581ec0..fe16f55 100644 --- a/fb_arc_set/shared/shm.c +++ b/fb_arc_set/shared/shm.c @@ -22,12 +22,14 @@ int create_shmfd(char *shm_name) { return shmfd; } -void* open_shm(int shmfd, size_t shm_size) { +void truncate_shm(int shmfd, size_t shm_size) { if(ftruncate(shmfd, shm_size) < 0) { fprintf(stderr, "ERROR: Failed truncating shared memory object\n"); exit(EXIT_FAILURE); } +} +void* open_shm(int shmfd, size_t shm_size) { void* shm; shm = mmap(NULL, shm_size, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0); diff --git a/fb_arc_set/supervisor.c b/fb_arc_set/supervisor.c index 7a18201..20ec17c 100644 --- a/fb_arc_set/supervisor.c +++ b/fb_arc_set/supervisor.c @@ -33,6 +33,7 @@ int main(int argc, char *argv[]) { /// Open shared memory objects int buffer_shmfd = create_shmfd(BUFFER_SHM_NAME); + truncate_shm(buffer_shmfd, BUFF_SIZE); circ_buffer = (buffer_t *)open_shm(buffer_shmfd, sizeof(buffer_t)); /// Open semaphores