Skip to content

Fix QSharedMemory on macOS with Qt 6.6+#215

Open
Omkar-Darekar wants to merge 1 commit into
itay-grudev:masterfrom
Omkar-Darekar:fix/macos-qt6-shared-memory
Open

Fix QSharedMemory on macOS with Qt 6.6+#215
Omkar-Darekar wants to merge 1 commit into
itay-grudev:masterfrom
Omkar-Darekar:fix/macos-qt6-shared-memory

Conversation

@Omkar-Darekar
Copy link
Copy Markdown

Qt 6.6+ defaults to POSIX Realtime shared memory via QNativeIpcKey on macOS. However, POSIX shared memory (shm_open) requires Qt to be built with -feature-ipc_posix and has strict naming requirements.

Many Qt installations (including Homebrew) don't have POSIX IPC enabled, causing the error:
QSharedMemory::KeyError "QSharedMemory::attach (shm_open): bad name"

Use legacyNativeKey() to force System V shared memory, which works reliably on all macOS configurations regardless of Qt build options.

Fixes single instance detection failing on macOS with Qt 6.6+.

Qt 6.6+ defaults to POSIX Realtime shared memory via QNativeIpcKey on
macOS. However, POSIX shared memory (shm_open) requires Qt to be built
with -feature-ipc_posix and has strict naming requirements.

Many Qt installations (including Homebrew) don't have POSIX IPC enabled,
causing the error:
  QSharedMemory::KeyError "QSharedMemory::attach (shm_open): bad name"

Use legacyNativeKey() to force System V shared memory, which works
reliably on all macOS configurations regardless of Qt build options.

Fixes single instance detection failing on macOS with Qt 6.6+.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant