mq_overview(7) Miscellaneous Information Manual mq_overview(7) mq_overview - POSIX POSIX . System V (msgget(2), msgsnd(2), msgrcv(2), etc.), . mq_open(3); (mqd_t), . /_; null NAME_MAX (. ., 255) , , (, ). , mq_open(3). mq_send(3) mq_receive(3). , mq_close(3), , mq_unlink(3). ( ) mq_getattr(3) mq_setattr(3). mq_notify(3). -- ( open(2)). fork(2) . (mq_flags), . , . : 0 () -- sysconf(_SC_MQ_PRIO_MAX) - 1 (). Linux, sysconf(_SC_MQ_PRIO_MAX) 32768, POSIX.1 0 31; . POSIX Linux. , mq_*() . : mq_close(3) close(2) mq_getattr(3) mq_getsetattr(2) mq_notify(3) mq_notify(2) mq_open(3) mq_open(2) mq_receive(3) mq_timedreceive(2) mq_send(3) mq_timedsend(2) mq_setattr(3) mq_getsetattr(2) mq_timedreceive(3) mq_timedreceive(2) mq_timedsend(3) mq_timedsend(2) mq_unlink(3) mq_unlink(2) POSIX message queues have been supported since Linux 2.6.6. glibc support has been provided since glibc 2.3.4. POSIX CONFIG_POSIX_MQUEUE. . POSIX . mq_unlink(3), . , POSIX, librt cc -lrt. /proc POSIX , : /proc/sys/fs/mqueue/msg_default ( Linux 3.5) This file defines the value used for a new queue's mq_maxmsg setting when the queue is created with a call to mq_open(3) where attr is specified as NULL. The default value for this file is 10. The minimum and maximum are as for /proc/sys/fs/mqueue/msg_max. A new queue's default mq_maxmsg value will be the smaller of msg_default and msg_max. Before Linux 2.6.28, the default mq_maxmsg was 10; from Linux 2.6.28 to Linux 3.4, the default was the value defined for the msg_max limit. /proc/sys/fs/mqueue/msg_max This file can be used to view and change the ceiling value for the maximum number of messages in a queue. This value acts as a ceiling on the attr->mq_maxmsg argument given to mq_open(3). The default value for msg_max is 10. The minimum value is 1 (10 before Linux 2.6.28). The upper limit is HARD_MSGMAX. The msg_max limit is ignored for privileged processes (CAP_SYS_RESOURCE), but the HARD_MSGMAX ceiling is nevertheless imposed. HARD_MSGMAX : o Up to Linux 2.6.32: 131072 / sizeof(void *) o Linux 2.6.33 to Linux 3.4: (32768 * sizeof(void *) / 4) o Linux 3.5: 65536 /proc/sys/fs/mqueue/msgsize_default ( Linux 3.5) This file defines the value used for a new queue's mq_msgsize setting when the queue is created with a call to mq_open(3) where attr is specified as NULL. The default value for this file is 8192 (bytes). The minimum and maximum are as for /proc/sys/fs/mqueue/msgsize_max. If msgsize_default exceeds msgsize_max, a new queue's default mq_msgsize value is capped to the msgsize_max limit. Before Linux 2.6.28, the default mq_msgsize was 8192; from Linux 2.6.28 to Linux 3.4, the default was the value defined for the msgsize_max limit. /proc/sys/fs/mqueue/msgsize_max This file can be used to view and change the ceiling on the maximum message size. This value acts as a ceiling on the attr->mq_msgsize argument given to mq_open(3). The default value for msgsize_max is 8192 bytes. The minimum value is 128 (8192 before Linux 2.6.28). The upper limit for msgsize_max has varied across kernel versions: o Linux 2.6.28 INT_MAX. o From Linux 2.6.28 to Linux 3.4, the limit is 1,048,576. o Linux 3.5 16777216 (HARD_MSGSIZEMAX). msgsize_max (CAP_SYS_RESOURCE), , Linux 3.5, HARD_MSGSIZEMAX. /proc/sys/fs/mqueue/queues_max . queues_max 256. queues_max ; (CAP_SYS_RESOURCE) ( ). RLIMIT_MSGQUEUE, , , ID, getrlimit(2). Linux ( , , , -). () : # mkdir /dev/mqueue # mount -t mqueue none /dev/mqueue . (, ls(1) rm(1)). , : $ cat /dev/mqueue/mymq QSIZE:129 NOTIFY:2 SIGNO:0 NOTIFY_PID:8260 : QSIZE ( ). NOTIFY_PID , PID mq_notify(3) , . NOTIFY : 0 -- SIGEV_SIGNAL; 1 -- SIGEV_NONE; 2 -- SIGEV_THREAD. SIGNO , SIGEV_SIGNAL. Linux Linux ( POSIX ). , select(2), poll(2) epoll(7). . close-on-exec ( open(2)) , mq_open(2). IPC POSIX IPC ipc_namespaces(7). System V (msgget(2), msgsnd(2), msgrcv(2) . .) -- . POSIX System V; , POSIX ( ) System V. Linux does not currently (Linux 2.6.26) support the use of access control lists (ACLs) for POSIX message queues. Since Linux 3.5 to Linux 3.14, the kernel imposed a ceiling of 1024 (HARD_QUEUESMAX) on the value to which the queues_max limit could be raised, and the ceiling was enforced even for privileged processes. This ceiling value was removed in Linux 3.14, and patches to stable Linux 3.5.x to Linux 3.13.x also removed the ceiling. ( ) QSIZE () . Linux 3.5 , , . Linux 4.2 ( ), . mq_notify(3). . getrlimit(2), mq_getsetattr(2), poll(2), select(2), mq_close(3), mq_getattr(3), mq_notify(3), mq_open(3), mq_receive(3), mq_send(3), mq_unlink(3), epoll(7), namespaces(7) aereiae , Alexey , Azamat Hackimov , Dmitriy S. Seregin , Dmitry Bolkhovskikh , ITriskTI , Max Is , Yuri Kozlov , ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . mq_overview(7)