Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

msgctl, msgctl64 - message control operations

&pagelevel(4)&pagelevel

Syntax

#include <sys/msg.h>

int msgctl(int msqid, int cmd, struct msqid_ds *buf);

CRTE111A30
int msgctl64(int msqid, int cmd, struct msqid_ds64 *buf); (End)

Description

Description msgctl() provides message control operations as specified by cmd. The possible values for cmd, and the message control operations they specify, are:

 

IPC_STAT

Place the current value of each member of the data structure associated with msqid into the structure pointed to by buf. The contents of this structure are defined in sys/msg.h.

 

IPC_SET

Set the value of the following members of the msgqid_ds data structure associated with msqid to the corresponding value found in the structure pointed to by buf:

msg_perm.uid
msg_perm.gid
msg_perm.mode
msg_qbytes

IPC_SET can only be executed by a process with appropriate privileges or a process that has an effective user ID equal to the value of msg_perm.cuid or msg_perm.uid in the msqid_ds data structure associated with msqid. Only a process with appropriate privileges can raise the value of msg_qbytes.

 

IPC_RMID

Remove the message queue identifier specified by msqid and destroy the message queue and the data structure associated with it. IPC_RMD can only be executed by a process with appropriate privileges or one that has an effective user ID equal to the value of msg_perm.cuid or msg_perm.uid in the msqid_ds data structure associated with msqid.


The function msgctl64() behaves like the function msgctl(), except that it uses the structure msgqid_ds64 instead of the structure msgqid_ds and therefore will work correctly after 01/19/2038 03:14:07 UTC.

The contents of the structure pointed to by buf include the following members:

struct ipc_perm msg_perm; /* operation permission struct */
struct msg     *msg_first;  /* ptr to first message on q */
struct msg     *msg_last;   /* ptr to last message on q */
ulong_t         msg_cbytes;     /* current # bytes on q */
msgqnum_t       msg_qnum;       /* # of messages on q */
msglen_t        msg_qbytes;     /* max # of bytes on q */
pid_t           msg_lspid;      /* pid of last msgsnd */
pid_t           msg_lrpid;      /* pid of last msgrcv */
time_t          msg_stime;      /* last msgsnd time */
time_t          msg_rtime;      /* last msgrcv time */
time_t          msg_ctime;      /* last change time */
The elements of the structure msqid64_ds are defined like those of the structure msqid_dswith the exception of the following components:
time64_t    msg_stime;
time64_t    msg_rtime;
time64_t    msg_ctime; 

Return val.

0

if successful.


-1

if an error occurs. errno is set to indicate the error.

Errors

msgctl() and msgctl64() will fail if:

 

EACCES

cmd is IPC_STAT and the calling process does not have read permission.

 

Extension

 

EFAULT

buf points to an invalid address. (End)

 

EINVAL

msqid is not a valid message queue identifier,
or cmd is not a valid operation,
or cmd is IPC_SET, and msg_perm.uid or msg_perm.gid is invalid.

 

EPERM

cmd is IPC_SET, and the effective user ID of the calling process is not equal to that of a process with appropriate privileges and not equal to the value of msg_perm.cuid or msg_perm.uid in the data structure associated with msqid.

 

EPERM

cmd is IPC_SET, an attempt is being made to increase to the value of msg_qbytes, and the effective user ID of the calling process does not have appropriate privileges.


msgctl64() will fail if:

 

EINVAL

POSIX-BC correction status < A47.

Notes

The IEEE 1003.4 Standards Committee is developing alternative interfaces for interprocess communication. Application developers who need to use interprocess communication (IPC) should design their applications so that modules using the IPC routines described here can be easily modified at a later date.

See also

msgget(), msgrcv(), msgsnd(), sys/msg.h, section “Interprocess communication”.