Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

msgctl(2) [netbsd man page]

MSGCTL(2)						      BSD System Calls Manual							 MSGCTL(2)

NAME
msgctl -- message control operations LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/msg.h> int msgctl(int msqid, int cmd, struct msqid_ds *buf); DESCRIPTION
The msgctl() system call performs control operations on the message queue specified by msqid. Each message queue has a msqid_ds structure associated with it which contains the following members: struct ipc_perm msg_perm; /* msg queue permission bits */ msgqnum_t msg_qnum; /* # of msgs in the queue */ msglen_t msg_qbytes; /* max # of bytes on the queue */ pid_t msg_lspid; /* pid of last msgsnd() */ pid_t msg_lrpid; /* pid of last msgrcv() */ time_t msg_stime; /* time of last msgsnd() */ time_t msg_rtime; /* time of last msgrcv() */ time_t msg_ctime; /* time of last msgctl() */ The ipc_perm structure used inside the msgid_ds structure is defined in <sys/ipc.h> and contains the following members: uid_t cuid; /* creator user id */ gid_t cgid; /* creator group id */ uid_t uid; /* user id */ gid_t gid; /* group id */ mode_t mode; /* permission (lower 9 bits) */ The operation to be performed by msgctl() is specified in cmd and is one of: IPC_STAT Gather information about the message queue and place it in the structure pointed to by buf. IPC_SET Set the value of the msg_perm.uid, msg_perm.gid, msg_perm.mode and msg_qbytes fields in the structure associated with msqid. The values are taken from the corresponding fields in the structure pointed to by buf. This operation can only be executed by the super-user, or a process that has an effective user id equal to either msg_perm.cuid or msg_perm.uid in the data structure associ- ated with the message queue. The value of msg_qbytes can only be increased by the super-user. Values for msg_qbytes that exceed the system limit (MSGMNB from <sys/msg.h>) are silently truncated to that limit. IPC_RMID Remove the message queue specified by msqid and destroy the data associated with it. Only the super-user or a process with an effective uid equal to the msg_perm.cuid or msg_perm.uid values in the data structure associated with the queue can do this. The permission to read from or write to a message queue (see msgsnd(2) and msgrcv(2)) is determined by the msg_perm.mode field in the same way as is done with files (see chmod(2)), but the effective uid can match either the msg_perm.cuid field or the msg_perm.uid field, and the effective gid can match either msg_perm.cgid or msg_perm.gid. RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise, -1 is returned and the global variable errno is set to indicate the error. ERRORS
msgctl() will fail if: [EPERM] cmd is equal to IPC_SET or IPC_RMID and the caller is not the super-user, nor does the effective uid match either the msg_perm.uid or msg_perm.cuid fields of the data structure associated with the message queue. An attempt was made to increase the value of msg_qbytes through IPC_SET, but the caller is not the super-user. [EACCES] cmd is IPC_STAT and the caller has no read permission for this message queue. [EINVAL] msqid is not a valid message queue identifier. cmd is not a valid command. [EFAULT] buf specifies an invalid address. SEE ALSO
msgget(2), msgrcv(2), msgsnd(2) STANDARDS
The msgctl system call conforms to X/Open System Interfaces and Headers Issue 5 (``XSH5''). HISTORY
Message queues appeared in the first release of AT&T System V UNIX. BSD
August 25, 1999 BSD

Check Out this Related Man Page

msgctl(2)							System Calls Manual							 msgctl(2)

NAME
msgctl - Performs message control operations SYNOPSIS
#include <sys/msg.h> int msgctl( int msqid, int cmd, struct msqid_ds *buf); Application developers may want to specify #include statements for <sys/types.h> and <sys/ipc.h> before the one for <sys/msg.h> if programs are being developed for multiple platforms. The additional #include statements are not required on Tru64 UNIX systems or by ISO or X/Open standards, but may be required on other vendors' systems that conform to these standards. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: msgctl(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the message queue ID. Specifies the type of command. The possible commands and the operations they perform are as follows: Queries the message queue ID by copying the contents of its associated data structure into the buf structure. The process must have manda- tory read access to the message queue with respect to all access control policies. Sets the message queue ID by copying values found in the buf structure into corresponding fields in the msqid_ds structure associated with the message queue ID. This operation is restricted. The effective user ID of the calling process must be equal to that of superuser or equal to the value of msg_perm.uid or msg_perm.cuid in the associated msqid_ds structure. Only superuser can raise the value of msg_qbytes. Removes the message queue ID and deallocates its associated msqid_ds structure. This operation is restricted. The effective user ID of the calling process must be equal to that of supe- ruser or equal to the value of msg_perm.uid or msg_perm.cuid in the associated msqid_ds structure. Points to a msqid_ds structure. This structure is used only with the IPC_STAT and IPC_SET commands. With IPC_STAT, the results of the query are copied to this structure. With IPC_SET, the values in this structure are used to set the corresponding fields in the msqid_ds structure associated with the message queue ID. In either case, the calling process must have allocated the structure before making the call. DESCRIPTION
The msgctl() function allows a process to query or set the contents of the msqid_ds structure associated with the specified message queue ID. It also allows a process to remove the message queue ID and its associated msqid_ds structure. The cmd value determines which opera- tion is performed. The IPC_SET command uses the user-supplied contents of the buf structure to set the following members of the msqid_ds structure associated with the message queue ID: The owner's user ID. The owner's group ID. The access modes for the queue. Only the low-order nine bits are set. The maximum number of bytes on the queue. The time of the last msgctl() operation that changed the structure. RETURN VALUES
Upon successful completion, msgctl( returns a value of 0 (zero). Otherwise, a value of -1 is returned and errno is set to indicate the error. ERRORS
The msgctl() function sets errno to the specified values for the following conditions: The cmd parameter is IPC_STAT, but the calling process does not have read permission. [Tru64 UNIX] The cmd parameter is IPC_STAT or IPC_SET, and an error occurred in accessing the buf structure. The msqid parameter is not a valid message queue ID, or the cmd parameter is not a valid command. The cmd parameter is equal to either IPC_RMID or IPC_SET, and the calling process does not have appropriate privilege. The cmd parameter is equal to IPC_SET, and an attempt is being made to increase the value of the msg_qbytes parameter when the calling process does not have the superuser privilege. RELATED INFORMATION
Functions: msgget(2), msgrcv(2), msgsnd(2) Data Structures: msqid_ds(4) Standards: standards(5) delim off msgctl(2)
Man Page