Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make macOS semaphore names more unique, improve assertion
On macOS, semaphore names are global and processes can open semaphores of other processes by using their name. It was possible that multiple client/server processes randomly tried to create semaphores with the same memory address, which would cause them to have the same name. In that case, `sem_open` would fail because `O_EXCL` prevents creating semaphores if the name is already used. This is made more unlikely by also including the PID in the semaphore name. Additionally, the semaphore name is prefixed with `/` to more closely follow the construction rules for semaphore names. In particular, the behavior is implementation-defined if the name is not prefixed with a slash. See https://pubs.opengroup.org/onlinepubs/9799919799/functions/sem_open.html Closes ddnet#8773. More details are added to the assertion error message in case this does not end up fixing the issue.
- Loading branch information