diff --git a/lib/libc/gen/msgget.3 b/lib/libc/gen/msgget.3 index b934f1c6b008..72a07e4be83f 100644 --- a/lib/libc/gen/msgget.3 +++ b/lib/libc/gen/msgget.3 @@ -46,15 +46,18 @@ returns the message queue identifier associated with .Fa key . A message queue identifier is a unique integer greater than zero. - +.Pp A message queue is created if either .Fa key -is equal to IPC_PRIVATE, or +is equal to +.Dv IPC_PRIVATE , +or .Fa key -does not have a message queue identifier associated with it, and the IPC_CREAT +does not have a message queue identifier associated with it, and the +.Dv IPC_CREAT bit is set in .Fa msgflg. - +.Pp If a new message queue is created, the data structure associated with it (the .Va msqid_ds structure, see @@ -83,11 +86,11 @@ is set to the lower 9 bits of .Va msg_rtime , and .Va msg_stime -are set to 0 +are set to 0. .It .Va msg_qbytes is set to the system wide maximum value for the number of bytes in a queue -(MSGMNB). +.Pf ( Dv MSGMNB ) . .It .Va msg_ctime is set to the current time. @@ -104,7 +107,11 @@ A message queue is already associated with .Fa key and the caller has no permission to access it. .It Bq Er EEXIST -Both IPC_CREAT and IPC_EXCL are set in +Both +.Dv IPC_CREAT +and +.Dv IPC_EXCL +are set in .Fa msgflg , and a message queue is already associated with .Fa key . @@ -112,7 +119,8 @@ and a message queue is already associated with A new message queue could not be created because the system limit for the number of message queues has been reached. .It Bq Er ENOENT -IPC_CREAT was not set in +.Dv IPC_CREAT +was not set in .Fa msgflg and no message queue associated with .Fa key diff --git a/lib/libc/gen/msgrcv.3 b/lib/libc/gen/msgrcv.3 index 6b4383711144..11099ca3341f 100644 --- a/lib/libc/gen/msgrcv.3 +++ b/lib/libc/gen/msgrcv.3 @@ -53,12 +53,13 @@ This structure should consist of the following members: long mtype; /* message type */ char mtext[1]; /* body of message */ .Ed - +.Pp .Va mtype is an integer greater than 0 that can be used for selecting messages, .Va mtext -is an array of bytes, with a size up to that of the system limit (MSGMAX). - +is an array of bytes, with a size up to that of the system limit +.Pf ( Dv MSGMAX ) . +.Pp The value of .Fa msgtyp has one of the following meanings: @@ -78,26 +79,36 @@ less than or equal to the absolute value of .Fa msgtyp will be received. .El - +.Pp .Fa msgsz specifies the maximum length of the requested message. If the received message has a length greater than .Fa msgsz -it will be silently truncated if the MSG_NOERROR flag is set in +it will be silently truncated if the +.Dv MSG_NOERROR +flag is set in .Fa msgflg , otherwise an error will be returned. - +.Pp If no matching message is present on the message queue specified by .Fa msqid , the behavior of .Fn msgrcv -depends on whether the IPC_NOWAIT flag is set in +depends on whether the +.Dv IPC_NOWAIT +flag is set in .Fa msgflg -or not. If IPC_NOWAIT is set, +or not. If +.Dv IPC_NOWAIT +is set, .Fn msgrcv will immediately return a value of -1, and set .Va errno -to EAGAIN. If IPC_NOWAIT is not set, the calling process will be blocked +to +.Er EAGAIN . +If +.Dv IPC_NOWAIT +is not set, the calling process will be blocked until: .Bl -bullet .It @@ -105,13 +116,15 @@ A message of the requested type becomes available on the message queue. .It The message queue is removed, in which case -1 will be returned, and .Va errno -set to EINVAL. +set to +.Er EINVAL . .It A signal is received and caught. -1 is returned, and .Va errno -set to EINTR. +set to +.Er EINTR . .El - +.Pp If a message is successfully received, the data structure associated with .Fa msqid is updated as follows: @@ -144,18 +157,20 @@ will fail if: .Bl -tag -width Er .It Bq Er EINVAL .Fa msqid -is not a valid message queue identifier - +is not a valid message queue identifier. +.Pp The message queue was removed while .Fn msgrcv was waiting for a message of the requested type to become available on it. - +.Pp .Fa msgsz is less than 0. .It Bq Er E2BIG A matching message was received, but its size was greater than .Fa msgsz -and the MSG_NOERROR flag was not set in +and the +.Dv MSG_NOERROR +flag was not set in .Fa msgflg . .It Bq Er EACCESS The calling process does not have read access to the message queue. @@ -166,16 +181,27 @@ points to an invalid address. The system call was interrupted by the delivery of a signal. .It Bq Er EAGAIN There is no message of the requested type available on the message queue, -and IPC_NOWAIT is set in +and +.Dv IPC_NOWAIT +is set in .Fa msgflg . .Sh SEE ALSO .Xr msgctl 3 , .Xr msgget 3 , .Xr msgsnd 3 .Sh BUGS -NetBSD and FreeBSD do not define the EIDRM error value, which should be used in -the case of a removed message queue, nor the ENOMSG value, which -should be used when no suitable message is available and IPC_NOWAIT +.Tn NetBSD +and +.Tn FreeBSD +do not define the +.Er EIDRM +error value, which should be used in +the case of a removed message queue, nor the +.Er ENOMSG +value, which +should be used when no suitable message is available and +.Dv IPC_NOWAIT is set. .Sh HISTORY -Message queues appeared in the first release of AT&T Unix System V. +Message queues appeared in the first release of +AT&T Unix System V. diff --git a/lib/libc/gen/msgsnd.3 b/lib/libc/gen/msgsnd.3 index 613ea4a2fbfa..5a3c80c9f2e5 100644 --- a/lib/libc/gen/msgsnd.3 +++ b/lib/libc/gen/msgsnd.3 @@ -53,17 +53,18 @@ consist of the following members: long mtype; /* message type */ char mtext[1]; /* body of message */ .Ed - +.Pp .Va mtype is an integer greater than 0 that can be used for selecting messages (see .Xr msgrcv 3 ) , .Va mtext -is an array of bytes, with a size up to that of the system limit (MSGMAX). - +is an array of bytes, with a size up to that of the system limit +.Pf ( Dv MSGMAX ) . +.Pp If the number of bytes already on the message queue plus .Fa msgsz -is bigger than the maximum number of bytes on the message queue ( -.Va msg_qbytes , +is bigger than the maximum number of bytes on the message queue +.Pf ( Va msg_qbytes , see .Xr msgctl 3 ) , or the number of messages on all queues system-wide is already equal to @@ -73,9 +74,13 @@ determines the action of .Fn msgsnd . If .Fa msgflg -has IPC_NOWAIT mask set in it, the call will return immediately. If +has +.Dv IPC_NOWAIT +mask set in it, the call will return immediately. If .Fa msgflg -does not have IPC_NOWAIT set in it, the call will block until: +does not have +.Dv IPC_NOWAIT +set in it, the call will block until: .Bl -bullet .It The condition which caused the call to block does no longer exist. @@ -83,13 +88,15 @@ The message will be sent. .It The message queue is removed, in which case -1 will be returned, and .Va errno -is set to EINVAL. +is set to +.Er EINVAL . .It The caller catches a signal. The call returns with .Va errno -set to EINTR. +set to +.Er EINTR . .El - +.Pp After a successful call, the data structure associated with the message queue is updated in the following way: .Bl -bullet @@ -117,12 +124,12 @@ will fail if: .It Bq Er EINVAL .Fa msqid is not a valid message queue identifier - +.Pp The message queue was removed while .Fn msgsnd was waiting for a resource to become available in order to deliver the message. - +.Pp .Fa msgsz is less than 0, or greater than .Va msg_qbytes . @@ -130,7 +137,9 @@ is less than 0, or greater than The calling process does not have write access to the message queue. .It Bq Er EAGAIN There was no space for this message either on the queue, or in the whole -system, and IPC_NOWAIT was set in +system, and +.Dv IPC_NOWAIT +was set in .Fa msgflg . .It Bq Er EFAULT .Fa msgp @@ -139,7 +148,12 @@ points to an invalid address. The system call was interrupted by the delivery of a signal. .El .Sh BUGS -NetBSD and FreeBSD do not define the EIDRM error value, which should be used +.Tn NetBSD +and +.Tn FreeBSD +do not define the +.Er EIDRM +error value, which should be used in the case of a removed message queue. .Sh HISTORY Message queues appeared in the first release of AT&T Unix System V.