1msgsnd(2)                        System Calls                        msgsnd(2)
2
3
4

NAME

6       msgsnd - message send operation
7

SYNOPSIS

9       #include <sys/msg.h>
10
11       int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);
12
13

DESCRIPTION

15       The msgsnd() function is used to send a message to the queue associated
16       with the message queue identifier specified by msqid.
17
18
19       The msgp argument points to a user-defined  buffer  that  must  contain
20       first  a  field of type long int that will specify the type of the mes‐
21       sage, and then a data portion that will hold the data bytes of the mes‐
22       sage.  The structure below is an example of what this user-defined buf‐
23       fer might look like:
24
25         struct  mymsg {
26                 long  mtype;     /* message type */
27                 char  mtext[1];  /* message text */
28         }
29
30
31
32       The mtype member is a non-zero positive type long int that can be  used
33       by the receiving process for message selection.
34
35
36       The  mtext member is any text of length msgsz bytes. The msgsz argument
37       can range from 0 to a system-imposed maximum.
38
39
40       The msgflg argument specifies the action to be taken if one or more  of
41       the following are true:
42
43           o      The  number  of  bytes  already  on  the  queue  is equal to
44                  msg_qbytes. See Intro(2).
45
46           o      The total number of messages on the queue would  exceed  the
47                  maximum allowed by the system. See NOTES.
48
49
50       These actions are as follows:
51
52           o      If  (msgflg&IPC_NOWAIT) is non-zero, the message will not be
53                  sent and the calling process will return immediately.
54
55           o      If (msgflg&IPC_NOWAIT) is 0, the calling process  will  sus‐
56                  pend execution until one of the following occurs:
57
58               o      The  condition  responsible for the suspension no longer
59                      exists, in which case the message is sent.
60
61               o      The message queue identifier msqid is removed  from  the
62                      system  (see  msgctl(2)); when this occurs, errno is set
63                      equal to EIDRM and −1 is returned.
64
65               o      The calling process receives a  signal  that  is  to  be
66                      caught;  in  this  case  the message is not sent and the
67                      calling process resumes execution  in  the  manner  pre‐
68                      scribed in sigaction(2).
69
70
71       Upon  successful  completion,  the  following  actions  are  taken with
72       respect to the data structure associated with msqid (see Intro(2)):
73
74           o      msg_qnum is incremented by 1.
75
76           o      msg_lspid is set equal to the  process  ID  of  the  calling
77                  process.
78
79           o      msg_stime is set equal to the current time.
80

RETURN VALUES

82       Upon  successful  completion, 0 is returned. Otherwise, −1 is returned,
83       no message is sent, and errno is set to indicate the error.
84

ERRORS

86       The msgsnd() function will fail if:
87
88       EACCES    Operation permission is denied to the  calling  process.  See
89                 Intro(2).
90
91
92       EAGAIN    The message cannot be sent for one of the reasons cited above
93                 and (msgflg&IPC_NOWAIT) is non-zero.
94
95
96       EIDRM     The message queue identifier msgid is removed from  the  sys‐
97                 tem.
98
99
100       EINTR     The msgsnd() function was interrupted by a signal.
101
102
103       EINVAL    The  value  of msqid is not a valid message queue identifier,
104                 or the value of mtype is less than 1.
105
106                 The value of msgsz is less than 0 or greater than the system-
107                 imposed limit.
108
109
110
111       The msgsnd() function may fail if:
112
113        EFAULT    The msgp argument points to an illegal address.
114
115

USAGE

117       The  value passed as the msgp argument should be converted to type void
118       *.
119

ATTRIBUTES

121       See attributes(5) for descriptions of the following attributes:
122
123
124
125
126       ┌─────────────────────────────┬─────────────────────────────┐
127       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
128       ├─────────────────────────────┼─────────────────────────────┤
129       │Interface Stability          │Standard                     │
130       └─────────────────────────────┴─────────────────────────────┘
131

SEE ALSO

133       rctladm(1M), Intro(2),  msgctl(2),  msgget(2),  msgrcv(2),  setrctl(2),
134       sigaction(2), attributes(5), standards(5)
135

NOTES

137       The  maximum number of messages allowed on a message queue is the mini‐
138       mum enforced value of the process.max-msg-messages resource control  of
139       the  creating  process  at  the time msgget(2) was used to allocate the
140       queue.
141
142
143        See rctladm(1M) and setrctl(2) for information  about  using  resource
144       controls.
145
146
147
148SunOS 5.11                        11 Feb 2003                        msgsnd(2)
Impressum