I see that you are filling the mqAttr structure, but not passing it to mq_open... it should not cause the error, but just noticed it.
Also, you are passing both O_EXCL and O_CREAT to mq_open... as per the opengroup documentation:
Quote:
mq_open
If O_EXCL and O_CREAT are set, mq_open() shall fail if the message queue name exists.
I do not see an EFAULT listed as a possible errno in the documentation, so its probably some sort of extension that your OS has implemented.
- What OS are you using?
- Try looking at the documentation for mq_open for your OS. It should detail what conditions cause the EFAULT error.
- Also, did you try running the code with a different queue name? do you get the same error every time?