Bug #2010
closed
POSIX message queue mq_open short form always EINVALs
Added by vsrinivas almost 14 years ago.
Updated almost 14 years ago.
Description
Hi,
Using the short form of mq_open(), (omitting the mode and mq attribute
structure) always returns EINVAL. The long form works fine.
DOESNT WORK ================
#include <sys/types.h>
#include <mqueue.h>
main() {
int i;
mq_open("naem", O_RDWR|O_CREAT|O_EXCL);
pause();
}
WORKS ======================
#include <sys/types.h>
#include <mqueue.h>
main() {
int i;
mq_open("nam", O_RDWR|O_CREAT|O_EXCL, 0777, NULL);
pause();
}
Quoting from the Austin Bible:
O_CREAT
Create a message queue. It requires two additional arguments: mode, which
shall be of type mode_t, and attr, which shall be a pointer to an mq_attr structure.
So, if the user doesn't provide the required extra arguments, all bets are off.
But!
I'll change the code to use the defaults, if none given. That would make
vsrinivas@ happy and allow me to check whether my commit access has expired due
to prolonged inactivity ;P
Cheers,
Stathis
P.S. And now someone jumps in the discussion and says that current behavior is
better, because failure draws the user's attention and makes her fix the code.
Quick follow-up.
After a discussion with corecode@ on IRC, it appears that it's impossible to fix
it without breaking the standard. So, I'll leave it as it is: a little bit
inconvenient, but aligned to the standard.
Stathis
Also available in: Atom
PDF