Skip to content

Commit 84bb801

Browse files
committed
Try to fix a communication problem caused by different permissions under linux
1 parent 5e5b347 commit 84bb801

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/libipc/platform/posix/shm_posix.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ id_t acquire(char const * name, std::size_t size, unsigned mode) {
6868
flag |= O_CREAT;
6969
break;
7070
}
71-
int fd = ::shm_open(op_name.c_str(), flag, S_IRUSR | S_IWUSR |
72-
S_IRGRP | S_IWGRP |
73-
S_IROTH | S_IWOTH);
71+
int fd = ::shm_open(op_name.c_str(), flag, 0);
7472
if (fd == -1) {
7573
ipc::error("fail shm_open[%d]: %s\n", errno, op_name.c_str());
7674
return nullptr;
7775
}
76+
::fchmod(fd, S_IRUSR | S_IWUSR |
77+
S_IRGRP | S_IWGRP |
78+
S_IROTH | S_IWOTH);
7879
auto ii = mem::alloc<id_info_t>();
7980
ii->fd_ = fd;
8081
ii->size_ = size;

0 commit comments

Comments
 (0)