lib/shared_memory: truncate semaphore length on macos

This commit is contained in:
Eli Mallon 2022-09-13 15:39:17 +02:00 committed by Thulinma
parent 7a4ac15fcf
commit 213128e82a
2 changed files with 14 additions and 2 deletions

View file

@ -75,8 +75,14 @@ namespace IPC{
///\param mode The mode in which to create the semaphore, if O_CREAT is given in oflag, ignored
/// otherwise \param value The initial value of the semaphore if O_CREAT is given in oflag,
/// ignored otherwise
void semaphore::open(const char *name, int oflag, mode_t mode, unsigned int value, bool noWait){
void semaphore::open(const char *sname, int oflag, mode_t mode, unsigned int value, bool noWait){
close();
char *name = (char*)sname;
if (strlen(sname) >= IPC_MAX_LEN) {
name = (char*)malloc(IPC_MAX_LEN + 1);
memcpy(name, sname, IPC_MAX_LEN);
name[IPC_MAX_LEN] = 0;
}
int timer = 0;
while (!(*this) && timer++ < 10){
#if defined(__CYGWIN__) || defined(_WIN32)