Cleanup of shared memory and semaphores

This commit is contained in:
zenon 2018-06-07 10:30:15 +02:00
parent 3af17e0d84
commit 93131dc027

View File

@ -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;
}