systemd-logind deletes your message queues (RemoveIPC)

Posted on

When something unexpected happens in a GNU/Linux system nowadays, it’s likely that systemd is involved somehow. If you want yet another spectacular example of how systemd and especially its author know what’s best for everyone, read on…

I wrote software for GNU/Linux where two processes communicate through a POSIX message queue (see man mq_overview or man mq_open).

So far so good, except that the message queue kept on disappearing after a while for no appearant reason.

I found that systemd mounts the mqueue-pseudo-filesystem at /dev/mqueue, which contains all message queues. It seemed quite likely that the queue was repeatedly being deleted from there.

A quickly written jprobe on mqueue_unlink revealed the culprit: systemd-logind.

Once again my gut-feeling that systemd is involved was right. Now if you (like I did) think this is a bug: It isn’t.

After reading the source and finding out that it’s actually default behaviour (see this commit) to remove “POSIX IPC Objects” when a user “fully logs out” (see bottom of man logind.conf) I wasn’t very surprised about You-Know-Who telling us that it’s the right thing to do by default.

My advise: Put RemoveIPC=no into your /etc/systemd/logind.conf or better avoid systemd altogether if you can. Here’s a collection of more systemd-crazyness.