lib/shared_memory: truncate semaphore length on macos
This commit is contained in:
parent
7a4ac15fcf
commit
213128e82a
2 changed files with 14 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue