msgctl.3p (5266B)
- '\" et
- .TH MSGCTL "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
- .\"
- .SH PROLOG
- This manual page is part of the POSIX Programmer's Manual.
- The Linux implementation of this interface may differ (consult
- the corresponding Linux manual page for details of Linux behavior),
- or the interface may not be implemented on Linux.
- .\"
- .SH NAME
- msgctl
- \(em XSI message control operations
- .SH SYNOPSIS
- .LP
- .nf
- #include <sys/msg.h>
- .P
- int msgctl(int \fImsqid\fP, int \fIcmd\fP, struct msqid_ds *\fIbuf\fP);
- .fi
- .SH DESCRIPTION
- The
- \fImsgctl\fR()
- function operates on XSI message queues (see the Base Definitions volume of POSIX.1\(hy2017,
- .IR "Section 3.226" ", " "Message Queue").
- It is unspecified whether this function interoperates with the
- realtime interprocess communication facilities defined in
- .IR "Section 2.8" ", " "Realtime".
- .P
- The
- \fImsgctl\fR()
- function shall provide message control operations as specified by
- .IR cmd .
- The following values for
- .IR cmd ,
- and the message control operations they specify, are:
- .IP IPC_STAT 12
- Place the current value of each member of the
- .BR msqid_ds
- data structure associated with
- .IR msqid
- into the structure pointed to by
- .IR buf .
- The contents of this structure are defined in
- .IR <sys/msg.h> .
- .IP IPC_SET 12
- Set the value of the following members of the
- .BR msqid_ds
- data structure associated with
- .IR msqid
- to the corresponding value found in the structure pointed to by
- .IR buf :
- .RS 12
- .sp
- .RS 4
- .nf
- msg_perm.uid
- msg_perm.gid
- msg_perm.mode
- msg_qbytes
- .fi
- .P
- .RE
- .P
- Also, the
- .IR msg_ctime
- timestamp shall be set to the current time, as described in
- .IR "Section 2.7.1" ", " "IPC General Description".
- .P
- IPC_SET can only be executed by a process with appropriate privileges
- or that has an effective user ID equal to the value of
- .BR msg_perm.cuid
- or
- .BR msg_perm.uid
- in the
- .BR msqid_ds
- data structure associated with
- .IR msqid .
- Only a process with appropriate privileges can raise the value of
- .BR msg_qbytes .
- .RE
- .IP IPC_RMID 12
- Remove the message queue identifier specified by
- .IR msqid
- from the system and destroy the message queue and
- .BR msqid_ds
- 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
- .BR msg_perm.cuid
- or
- .BR msg_perm.uid
- in the
- .BR msqid_ds
- data structure associated with
- .IR msqid .
- .SH "RETURN VALUE"
- Upon successful completion,
- \fImsgctl\fR()
- shall return 0; otherwise, it shall return \-1 and set
- .IR errno
- to indicate the error.
- .SH ERRORS
- The
- \fImsgctl\fR()
- function shall fail if:
- .TP
- .BR EACCES
- The argument
- .IR cmd
- is IPC_STAT and the calling process does not have read permission; see
- .IR "Section 2.7" ", " "XSI Interprocess Communication".
- .TP
- .BR EINVAL
- The value of
- .IR msqid
- is not a valid message queue identifier; or the value of
- .IR cmd
- is not a valid command.
- .TP
- .BR EPERM
- The argument
- .IR cmd
- is IPC_RMID or IPC_SET
- and the effective user ID of the calling process is not equal to that
- of a process with appropriate privileges and it is not equal to the
- value of
- .BR msg_perm.cuid
- or
- .BR msg_perm.uid
- in the data structure associated with
- .IR msqid .
- .TP
- .BR EPERM
- The argument
- .IR cmd
- is IPC_SET, an attempt is being made to increase to the value of
- .BR msg_qbytes ,
- and the effective user ID of the calling process does not have
- appropriate privileges.
- .LP
- .IR "The following sections are informative."
- .SH EXAMPLES
- None.
- .SH "APPLICATION USAGE"
- The POSIX Realtime Extension defines alternative interfaces for interprocess communication
- (IPC). Application developers who need to use IPC should design their
- applications so that modules using the IPC routines described in
- .IR "Section 2.7" ", " "XSI Interprocess Communication"
- can be easily modified to use the alternative interfaces.
- .SH RATIONALE
- None.
- .SH "FUTURE DIRECTIONS"
- None.
- .SH "SEE ALSO"
- .IR "Section 2.7" ", " "XSI Interprocess Communication",
- .IR "Section 2.8" ", " "Realtime",
- .IR "\fImq_close\fR\^(\|)",
- .IR "\fImq_getattr\fR\^(\|)",
- .IR "\fImq_notify\fR\^(\|)",
- .IR "\fImq_open\fR\^(\|)",
- .IR "\fImq_receive\fR\^(\|)",
- .IR "\fImq_send\fR\^(\|)",
- .IR "\fImq_setattr\fR\^(\|)",
- .IR "\fImq_unlink\fR\^(\|)",
- .IR "\fImsgget\fR\^(\|)",
- .IR "\fImsgrcv\fR\^(\|)",
- .IR "\fImsgsnd\fR\^(\|)"
- .P
- The Base Definitions volume of POSIX.1\(hy2017,
- .IR "Section 3.226" ", " "Message Queue",
- .IR "\fB<sys_msg.h>\fP"
- .\"
- .SH COPYRIGHT
- Portions of this text are reprinted and reproduced in electronic form
- from IEEE Std 1003.1-2017, Standard for Information Technology
- -- Portable Operating System Interface (POSIX), The Open Group Base
- Specifications Issue 7, 2018 Edition,
- Copyright (C) 2018 by the Institute of
- Electrical and Electronics Engineers, Inc and The Open Group.
- In the event of any discrepancy between this version and the original IEEE and
- The Open Group Standard, the original IEEE and The Open Group Standard
- is the referee document. The original Standard can be obtained online at
- http://www.opengroup.org/unix/online.html .
- .PP
- Any typographical or formatting errors that appear
- in this page are most likely
- to have been introduced during the conversion of the source files to
- man page format. To report such errors, see
- https://www.kernel.org/doc/man-pages/reporting_bugs.html .