POSIX Message Queue Sucks
mq_open
sucks on Linux. By the POSIX standard, it probably sucks everywhere.
To create an anonymous message queue, you have to do mq_open(name, O_CREAT|O_EXCL|O_RDWR, _, _)
followed by mq_unlink(name)
. The operation (2 syscalls) is atomic, but
- message queue leaks if the program stops in between the two calls. there’s no safe way to delete those message queues without stopping the world.
- if
mq_open
fails, you have to pick another name.
I guess I’ll stick to futex
-based message queue implementations. Notable mentions are Zig’s std
queue and libzmq.
Better yet, I will not write threaded programs if I don’t have to.