MSGCTL(3)                  POSIX Programmer's Manual                 MSGCTL(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       msgctl -- XSI message control operations

SSYYNNOOPPSSIISS
       #include <sys/msg.h>

       int msgctl(int _m_s_q_i_d, int _c_m_d, struct msqid_ds *_b_u_f);

DDEESSCCRRIIPPTTIIOONN
       The _m_s_g_c_t_l() function operates on XSI message queues (see the Base
       Definitions volume of POSIX.1-2008, _S_e_c_t_i_o_n _3_._2_2_5, _M_e_s_s_a_g_e _Q_u_e_u_e).  It
       is unspecified whether this function interoperates with the realtime
       interprocess communication facilities defined in _S_e_c_t_i_o_n _2_._8, _R_e_a_l_t_i_m_e.

       The _m_s_g_c_t_l() function shall provide message control operations as
       specified by _c_m_d.  The following values for _c_m_d, and the message
       control operations they specify, are:

       IPC_STAT    Place the current value of each member of the mmssqqiidd__ddss data
                   structure associated with _m_s_q_i_d into the structure pointed
                   to by _b_u_f.  The contents of this structure are defined in
                   _<_s_y_s_/_m_s_g_._h_>.

       IPC_SET     Set the value of the following members of the mmssqqiidd__ddss data
                   structure associated with _m_s_q_i_d to the corresponding value
                   found in the structure pointed to by _b_u_f:

                       mmssgg__ppeerrmm..uuiidd
                       mmssgg__ppeerrmm..ggiidd
                       mmssgg__ppeerrmm..mmooddee
                       mmssgg__qqbbyytteess

                   Also, the _m_s_g___c_t_i_m_e timestamp shall be set to the current
                   time, as described in _S_e_c_t_i_o_n _2_._7_._1, _I_P_C _G_e_n_e_r_a_l
                   _D_e_s_c_r_i_p_t_i_o_n.

                   IPC_SET can only be executed by a process with appropriate
                   privileges or that has an effective user ID equal to the
                   value of mmssgg__ppeerrmm..ccuuiidd or mmssgg__ppeerrmm..uuiidd in the mmssqqiidd__ddss data
                   structure associated with _m_s_q_i_d.  Only a process with
                   appropriate privileges can raise the value of mmssgg__qqbbyytteess.

       IPC_RMID    Remove the message queue identifier specified by _m_s_q_i_d from
                   the system and destroy the message queue and mmssqqiidd__ddss 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 mmssgg__ppeerrmm..ccuuiidd or
                   mmssgg__ppeerrmm..uuiidd in the mmssqqiidd__ddss data structure associated with
                   _m_s_q_i_d.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, _m_s_g_c_t_l() shall return 0; otherwise, it
       shall return -1 and set _e_r_r_n_o to indicate the error.

EERRRROORRSS
       The _m_s_g_c_t_l() function shall fail if:

       EEAACCCCEESS The argument _c_m_d is IPC_STAT and the calling process does not
              have read permission; see _S_e_c_t_i_o_n _2_._7, _X_S_I _I_n_t_e_r_p_r_o_c_e_s_s
              _C_o_m_m_u_n_i_c_a_t_i_o_n.

       EEIINNVVAALL The value of _m_s_q_i_d is not a valid message queue identifier; or
              the value of _c_m_d is not a valid command.

       EEPPEERRMM  The argument _c_m_d 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
              mmssgg__ppeerrmm..ccuuiidd or mmssgg__ppeerrmm..uuiidd in the data structure associated
              with _m_s_q_i_d.

       EEPPEERRMM  The argument _c_m_d is IPC_SET, an attempt is being made to
              increase to the value of mmssgg__qqbbyytteess, and the effective user ID
              of the calling process does not have appropriate privileges.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       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 _S_e_c_t_i_o_n _2_._7, _X_S_I _I_n_t_e_r_p_r_o_c_e_s_s _C_o_m_m_u_n_i_c_a_t_i_o_n can
       be easily modified to use the alternative interfaces.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _S_e_c_t_i_o_n _2_._7, _X_S_I _I_n_t_e_r_p_r_o_c_e_s_s _C_o_m_m_u_n_i_c_a_t_i_o_n, _S_e_c_t_i_o_n _2_._8, _R_e_a_l_t_i_m_e,
       _m_q___c_l_o_s_e(), _m_q___g_e_t_a_t_t_r(), _m_q___n_o_t_i_f_y(), _m_q___o_p_e_n(), _m_q___r_e_c_e_i_v_e(),
       _m_q___s_e_n_d(), _m_q___s_e_t_a_t_t_r(), _m_q___u_n_l_i_n_k(), _m_s_g_g_e_t(), _m_s_g_r_c_v(), _m_s_g_s_n_d()

       The Base Definitions volume of POSIX.1-2008, _S_e_c_t_i_o_n _3_._2_2_5, _M_e_s_s_a_g_e
       _Q_u_e_u_e, <<ssyyss__mmssgg..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) 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.unix.org/online.html .

       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 .



IEEE/The Open Group                  2013                            MSGCTL(3)
