diff --git a/supervisor.c b/supervisor.c index 92f5de4..5317b03 100644 --- a/supervisor.c +++ b/supervisor.c @@ -89,5 +89,25 @@ int main(int argc, char *argv[]) } + shared->quit = 1; + + if (munmap(shared, sizeof(*shared)) == -1) { + perror("munmap"); + exit(EXIT_FAILURE); + } + + close(shmfd); + + if (shm_unlink(SHM_NAME) == -1) { + perror("shm_unlink"); + exit(EXIT_FAILURE); + } + + sem_close(sUsedSpace); + sem_close(sFreeSpace); + + sem_unlink(SEM_USED_SPACE); + sem_unlink(SEM_FREE_SPACE); + return 0; }