diff --git a/lib/shared_memory.cpp b/lib/shared_memory.cpp index cb8e81c6..bcb3405e 100644 --- a/lib/shared_memory.cpp +++ b/lib/shared_memory.cpp @@ -348,6 +348,18 @@ namespace IPC { close(); } + /// Returns true if the open file still exists. + /// Not implemented under Windows. + bool sharedPage::exists(){ +#ifdef SHM_ENABLED + struct stat sb; + if (fstat(handle, &sb)){return false;} + return (sb.st_nlink > 0); +#else + return true; +#endif + } + #ifdef SHM_ENABLED ///\brief Unmaps a shared page if allowed void sharedPage::unmap() { diff --git a/lib/shared_memory.h b/lib/shared_memory.h index 5e329e68..f615acdd 100644 --- a/lib/shared_memory.h +++ b/lib/shared_memory.h @@ -109,6 +109,7 @@ namespace IPC { bool operator < (const sharedFile & rhs) const { return name < rhs.name; } + bool exists(){return true;} void close(); void unmap(); ///\brief The fd handle of the opened shared file @@ -143,6 +144,7 @@ namespace IPC { } void unmap(); void close(); + bool exists(); #if defined(__CYGWIN__) || defined(_WIN32) ///\brief The handle of the opened shared memory page HANDLE handle;