Added sharedPage::exists() call

This commit is contained in:
Thulinma 2018-02-09 13:44:53 +01:00
parent 12d18bd7c5
commit bea8678df9
2 changed files with 14 additions and 0 deletions

View file

@ -348,6 +348,18 @@ namespace IPC {
close(); 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 #ifdef SHM_ENABLED
///\brief Unmaps a shared page if allowed ///\brief Unmaps a shared page if allowed
void sharedPage::unmap() { void sharedPage::unmap() {

View file

@ -109,6 +109,7 @@ namespace IPC {
bool operator < (const sharedFile & rhs) const { bool operator < (const sharedFile & rhs) const {
return name < rhs.name; return name < rhs.name;
} }
bool exists(){return true;}
void close(); void close();
void unmap(); void unmap();
///\brief The fd handle of the opened shared file ///\brief The fd handle of the opened shared file
@ -143,6 +144,7 @@ namespace IPC {
} }
void unmap(); void unmap();
void close(); void close();
bool exists();
#if defined(__CYGWIN__) || defined(_WIN32) #if defined(__CYGWIN__) || defined(_WIN32)
///\brief The handle of the opened shared memory page ///\brief The handle of the opened shared memory page
HANDLE handle; HANDLE handle;