From 6c7d71361a993d24f474e457f91cdedaa83048e3 Mon Sep 17 00:00:00 2001 From: Andy Bauer Date: Sun, 13 Nov 2016 16:40:54 -0600 Subject: [PATCH] unlink the mmap file when the monitor object is destroyed --- src/zm_monitor.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index f99ebd82d..e14340743 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -674,6 +674,13 @@ Monitor::~Monitor() if ( munmap( mem_ptr, mem_size ) < 0 ) Fatal( "Can't munmap: %s", strerror(errno) ); close( map_fd ); + + char mmap_path[PATH_MAX] = ""; + snprintf( mmap_path, sizeof(mmap_path), "%s/zm.mmap.%d", config.path_map, id ); + + if ( unlink( mmap_path ) < 0 ) { + Warning( "Can't unlink '%s': %s", mmap_path, strerror(errno) ); + } #else // ZM_MEM_MAPPED struct shmid_ds shm_data; if ( shmctl( shm_id, IPC_STAT, &shm_data ) < 0 ) {