Move the clean_up function and add it to generator
This commit is contained in:
@@ -52,3 +52,26 @@ static void process_signal(void){
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
sigaction(SIGTERM, &sa, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function to that cleans up the resources
|
||||
* @details The function closes and destroys all semaphores,
|
||||
* closes and destroys all shared memory objects and
|
||||
* closes the file descriptors
|
||||
* @param none
|
||||
* @return none
|
||||
**/
|
||||
static void clean_up(void) {
|
||||
/// Close and destory semaphores
|
||||
close_sem(free_sem);
|
||||
close_sem(use_sem);
|
||||
close_sem(mutex);
|
||||
|
||||
destroy_sem(FREE_SEM_NAME);
|
||||
destroy_sem(USE_SEM_NAME);
|
||||
destroy_sem(MUTEX_NAME);
|
||||
|
||||
/// Close and destroy shared memory objects
|
||||
close_shm(circ_buffer, sizeof(buffer_t));
|
||||
destroy_shm(BUFF_SHM_NAME, buffer_shmfd);
|
||||
}
|
||||
|
Reference in New Issue
Block a user