MSGGET(3)                  POSIX Programmer's Manual                 MSGGET(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
       msgget -- get the XSI message queue identifier

SSYYNNOOPPSSIISS
       #include <sys/msg.h>

       int msgget(key_t _k_e_y, int _m_s_g_f_l_g);

DDEESSCCRRIIPPTTIIOONN
       The _m_s_g_g_e_t() 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_g_e_t() function shall return the message queue identifier
       associated with the argument _k_e_y.

       A message queue identifier, associated message queue, and data
       structure (see _<_s_y_s_/_m_s_g_._h_>), shall be created for the argument _k_e_y if
       one of the following is true:

        *  The argument _k_e_y is equal to IPC_PRIVATE.

        *  The argument _k_e_y does not already have a message queue identifier
           associated with it, and (_m_s_g_f_l_g & IPC_CREAT) is non-zero.

       Upon creation, the data structure associated with the new message queue
       identifier shall be initialized as follows:

        *  mmssgg__ppeerrmm..ccuuiidd, mmssgg__ppeerrmm..uuiidd, mmssgg__ppeerrmm..ccggiidd, and mmssgg__ppeerrmm..ggiidd shall
           be set to the effective user ID and effective group ID,
           respectively, of the calling process.

        *  The low-order 9 bits of mmssgg__ppeerrmm..mmooddee shall be set to the low-order
           9 bits of _m_s_g_f_l_g.

        *  mmssgg__qqnnuumm, mmssgg__llssppiidd, mmssgg__llrrppiidd, mmssgg__ssttiimmee, and mmssgg__rrttiimmee shall be
           set to 0.

        *  mmssgg__ccttiimmee 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.

        *  mmssgg__qqbbyytteess shall be set to the system limit.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, _m_s_g_g_e_t() shall return a non-negative
       integer, namely a message queue identifier.  Otherwise, it shall return
       -1 and set _e_r_r_n_o to indicate the error.

EERRRROORRSS
       The _m_s_g_g_e_t() function shall fail if:

       EEAACCCCEESS A message queue identifier exists for the argument _k_e_y, but
              operation permission as specified by the low-order 9 bits of
              _m_s_g_f_l_g would not be granted; 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.

       EEEEXXIISSTT A message queue identifier exists for the argument _k_e_y but
              ((_m_s_g_f_l_g & IPC_CREAT) && (_m_s_g_f_l_g & IPC_EXCL)) is non-zero.

       EENNOOEENNTT A message queue identifier does not exist for the argument _k_e_y
              and (_m_s_g_f_l_g & IPC_CREAT) is 0.

       EENNOOSSPPCC A message queue identifier is to be created but the system-
              imposed limit on the maximum number of allowed message queue
              identifiers system-wide would be exceeded.

       _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,
       _f_t_o_k(), _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_c_t_l(), _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                            MSGGET(3)
