Take the 2-minute tour ×
gcc 4.7.2 c89


I am using posix message queues: mq_create, mq_send, mq_receive, etc.

I am trying to find out what the default message size (attr.msgsize) and max messages (attr.maxmsg) that the kernal supports.

Currently I have done like this to set the defaults myself:


And when I get an input from the user on the command line I will use them to set the default if the user enters a value that goes beyould these defaults:

long msg_size = atol(optarg);
attr->mq_msgsize = 
    (msg_size > MQ_MSGSIZE_DEFAULT ? MQ_MSGSIZE_DEFAULT : msg_size);

However, this is not very portable as I have hardcoded the default values when could be different on different platforms.

Is there system calls that I can use to get the default values?

Many thanks for any suggestions,

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You can get the value by reading from proc file system /proc/sys/fs/mqueue/msgsize_max

share|improve this answer
add comment

Your Answer


