summaryrefslogtreecommitdiff
path: root/base/SharedMemory_posix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'base/SharedMemory_posix.cpp')
-rw-r--r--base/SharedMemory_posix.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/base/SharedMemory_posix.cpp b/base/SharedMemory_posix.cpp
index 5198a6df..7bb91c8e 100644
--- a/base/SharedMemory_posix.cpp
+++ b/base/SharedMemory_posix.cpp
@@ -91,6 +91,11 @@ int SharedMemory::openInternal(int oflag, int mode, bool doMapping) {
mFd = shm_open(mName.c_str(), oflag, mode);
} else {
mFd = ::open(mName.c_str(), oflag, mode);
+ // Make sure the file can hold at least mSize bytes..
+ struct stat stat;
+ if (!fstat(mFd, &stat) && stat.st_size < mSize) {
+ ftruncate(mFd, mSize);
+ }
}
if (mFd == -1) {
err = -errno;