I am trying to compile the example from nix's mqueue module and it is panicking on mq_open with EINVAL.
I have re-implemented this code in C and it worked perfectly and moreover, once the message queue was formed this code no longer panicked and ran just fine. If I manually created the file in /dev/mqueue/ it was happy. I used the same flags and everything in the C version and that ran with no problems at all.
This has been driving me crazy enough I even went back and tried it on an older distro, Rocky Linux 9 *spits*, and it had the exact same result. So far I have tried this on latest Debian, RL9, and NixOS unstable.
Here is my code straight from the example with the fs and mqueue features active:
use nix::mqueue::{mq_attr_member_t, mq_close, mq_open, mq_receive, mq_send, MQ_OFlag};
use nix::sys::stat::Mode;
fn main() {
const MSG_SIZE: mq_attr_member_t = 32;
let mq_name = "/a_nix_test_queue";
let oflag0 = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY;
let mode = Mode::S_IWUSR | Mode::S_IRUSR | Mode::S_IRGRP | Mode::S_IROTH;
let mqd0 = mq_open(mq_name, oflag0, mode, None).unwrap();
let msg_to_send = b"msg_1";
mq_send(&mqd0, msg_to_send, 1).unwrap();
let oflag1 = MQ_OFlag::O_CREAT | MQ_OFlag::O_RDONLY;
let mqd1 = mq_open(mq_name, oflag1, mode, None).unwrap();
let mut buf = [0u8; 32];
let mut prio = 0u32;
let len = mq_receive(&mqd1, &mut buf, &mut prio).unwrap();
assert_eq!(prio, 1);
assert_eq!(msg_to_send, &buf[0..len]);
mq_close(mqd1).unwrap();
mq_close(mqd0).unwrap();
}
Posix Message Queue functions