Using IPC on Linux using Swift


Is there a way to access IPC features (semaphores, shared memory, and message queues) on Linux using Swift directly? Is there a swift module for that?

Thank you.


1 Like

The swift module for that, at least the one that ships with the standard distribution, is Glibc. This gets you some of what you need: for your specific queries, sem_open and mmap (with MAP_SHARED) are both present and functioning.

For message queues a quick test suggests that the Glibc module doesn't expose them, and a dive into the Swift codebase suggests that mqueue.h is not in the module map for Glibc here. A good long-term value-add would be to bring this in to Glibc, but if you want just the fastest solution to the problem you will need to build a module that pulls this in yourself. SwiftPM has some documentation on this.


Thank you. I'll look into them.