LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-05-2005, 10:55 AM   #1
supaflav
LQ Newbie
 
Registered: Oct 2005
Location: Ottawa, ON, CANADA
Distribution: Suse 9.3
Posts: 1

Rep: Reputation: 0
Question mq_open fails on Suse 9.2 / 9.3


Getting frustrated trying to get mq_open to work on Suse 9.2 or 9.3.
I use the following code ...


#include <mqueue.h>

....

mqid = mq_open ("msg_queue", O_CREAT | O_RDWR | O_EXCL);
if (mqid == -1)
{
perror("mq_open failed");
}

Compiled using the -lrt library.

When I run the program, perror returns 'Invalid argument'.
This is not even a valid error? mq_open always returns -1!
Has anyone had any success with mq_open on Suse?

Cheers,
 
Old 11-04-2005, 01:12 PM   #2
lavaman
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Rep: Reputation: 0
The probelm is that if you run mq_open with O_CREAT, it requires two more arguments:

mq_open(name, O_FLAGS, mode, mq_attr);

where mode is your standard S_IWUSR, S_IRUSR, etc. from sys/stat.h and mq_attr is a struct mq_attr with the number of messages and message size specified.

If you want to use the defaults, you can pass NULL for the last argument.

See mqueue.h for members of mq_attr.

The name of your mqueue must also follow the convention of one single "/" followed by the name with no other "/"s in the name.
You have no option of where the mqueue is created in the filesystem.
It will always be created in /dev/mqueue and you must create that directory and mount the mqueue filesystem there as well.

Also note that the flags member of mq_attr is ignored by mq_open and that flags is the ONLY member of mq_attr used by mq_setattr().

Last edited by lavaman; 11-04-2005 at 01:13 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
WG511 V2 Fails in Suse 9.3 GetLinux SUSE / openSUSE 6 04-24-2005 03:35 AM
shmget fails in suse 9 but works on suse 8 dcsadler SUSE / openSUSE 0 02-02-2005 10:37 PM
Insallation of Suse 8.1 Professional Fails (But Never Used To!) wmeler Linux From Scratch 5 02-03-2004 07:56 AM
SuSE 7.3 to 8 upgrade fails - no IDE chasv Linux - Hardware 2 06-29-2003 09:11 AM
SUSE Install Fails... iamPlace Linux - Software 2 06-17-2003 02:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration