Manual Pages for Linux CentOS command on man msgctl
MyWebUniversity

Manual Pages for Linux CentOS command on man msgctl

MSGCTL(2) Linux Programmer's Manual MSGCTL(2)

NAME

msgctl - System V message control operations SYNOPSIS

#include

#include

#include int msgctl(int msqid, int cmd, struct msqidds *buf); DESCRIPTION msgctl() performs the control operation specified by cmd on the System V message queue with identifier msqid. The msqidds data structure is defined in as follows: struct msqidds { struct ipcperm msgperm; /* Ownership and permissions */ timet msgstime; /* Time of last msgsnd(2) */ timet msgrtime; /* Time of last msgrcv(2) */ timet msgctime; /* Time of last change */ unsigned long msgcbytes; /* Current number of bytes in queue (nonstandard) */ msgqnumt msgqnum; /* Current number of messages in queue */ msglent msgqbytes; /* Maximum number of bytes allowed in queue */ pidt msglspid; /* PID of last msgsnd(2) */ pidt msglrpid; /* PID of last msgrcv(2) */ }; The ipcperm structure is defined as follows (the highlighted fields are settable using IPCSET): struct ipcperm { keyt key; /* Key supplied to msgget(2) */ uidt uid; /* Effective UID of owner */ gidt gid; /* Effective GID of owner */ uidt cuid; /* Effective UID of creator */ gidt cgid; /* Effective GID of creator */ unsigned short mode; /* Permissions */ unsigned short seq; /* Sequence number */ }; Valid values for cmd are: IPCSTAT Copy information from the kernel data structure associated with msqid into the msqidds structure pointed to by buf. The caller must have read permission on the message queue. IPCSET Write the values of some members of the msqidds structure pointed to by buf to the kernel data structure associated with this message queue, updating also its msgctime member. The following members of the structure are updated: msgqbytes, msgperm.uid, msgperm.gid, and (the least significant 9 bits of) msgperm.mode. The effective UID of the calling process must match the owner (msgperm.uid) or creator (msgperm.cuid) of the message queue, or the caller must be privileged. Appro‐ priate privilege (Linux: the CAPIPCRESOURCE capability) is required to raise the msgqbytes value beyond the system parame‐ ter MSGMNB. IPCRMID Immediately remove the message queue, awakening all waiting reader and writer processes (with an error return and errno set to EIDRM). The calling process must have appropriate privileges or its effective user ID must be either that of the creator or owner of the message queue.

IPCINFO (Linux-specific)

Returns information about system-wide message queue limits and parameters in the structure pointed to by buf. This structure is of type msginfo (thus, a cast is required), defined in if the GNUSOURCE feature test macro is defined: struct msginfo { int msgpool; /* Size in kibibytes of buffer pool used to hold message data; unused within kernel */ int msgmap; /* Maximum number of entries in message map; unused within kernel */ int msgmax; /* Maximum number of bytes that can be written in a single message */ int msgmnb; /* Maximum number of bytes that can be written to queue; used to initialize msgqbytes during queue creation (msgget(2)) */ int msgmni; /* Maximum number of message queues */ int msgssz; /* Message segment size; unused within kernel */ int msgtql; /* Maximum number of messages on all queues in system; unused within kernel */ unsigned short int msgseg; /* Maximum number of segments; unused within kernel */ }; The msgmni, msgmax, and msgmnb settings can be changed via /proc files of the same name; see proc(5) for details.

MSGINFO (Linux-specific) Returns a msginfo structure containing the same information as for IPCINFO, except that the following fields are returned with information about system resources consumed by message queues: the msgpool field returns the number of message queues that cur‐ rently exist on the system; the msgmap field returns the total number of messages in all queues on the system; and the msgtql field returns the total number of bytes in all messages in all queues on the system.

MSGSTAT (Linux-specific) Returns a msqidds structure as for IPCSTAT. However, the msqid argument is not a queue identifier, but instead an index into the kernel's internal array that maintains information about all message queues on the system. RETURN VALUE On success, IPCSTAT, IPCSET, and IPCRMID return 0. A successful IPCINFO or MSGINFO operation returns the index of the highest used entry in the kernel's internal array recording information about all message queues. (This information can be used with repeated MSGSTAT operations to obtain information about all queues on the system.) A successful MSGSTAT operation returns the identifier of the queue whose index was given in msqid.

On error, -1 is returned with errno indicating the error. ERRORS On failure, errno is set to one of the following: EACCES The argument cmd is equal to IPCSTAT or MSGSTAT, but the call‐ ing process does not have read permission on the message queue msqid, and does not have the CAPIPCOWNER capability. EFAULT The argument cmd has the value IPCSET or IPCSTAT, but the address pointed to by buf isn't accessible. EIDRM The message queue was removed. EINVAL Invalid value for cmd or msqid. Or: for a MSGSTAT operation, the index value specified in msqid referred to an array slot that is currently unused. EPERM The argument cmd has the value IPCSET or IPCRMID, but the effective user ID of the calling process is not the creator (as found in msgperm.cuid) or the owner (as found in msgperm.uid) of the message queue, and the process is not privileged (Linux: it does not have the CAPSYSADMIN capability). CONFORMING TO

SVr4, POSIX.1-2001. NOTES The inclusion of and isn't required on Linux or by any version of POSIX. However, some old implementations required the inclusion of these header files, and the SVID also documented their inclusion. Applications intended to be portable to such old systems may need to include these header files. The IPCINFO, MSGSTAT and MSGINFO operations are used by the ipcs(1) program to provide information on allocated resources. In the future these may modified or moved to a /proc file system interface. Various fields in the struct msqidds were typed as short under Linux 2.2 and have become long under Linux 2.4. To take advantage of this, a

recompilation under glibc-2.1.91 or later should suffice. (The kernel distinguishes old and new calls by an IPC64 flag in cmd.) SEE ALSO msgget(2), msgrcv(2), msgsnd(2), capabilities(7), mqoverview(7), svipc(7) COLOPHON

This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can

be found at http://www.kernel.org/doc/man-pages/.

Linux 2012-05-31 MSGCTL(2)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™