Penguin
Annotated edit history of msgget(2) version 2, including all changes. View license author blame.
Rev Author # Line
1 perry 1 !!NAME
2 PerryLorier 2 msgget - get a message queue identifier
1 perry 3
4 !!SYNOPSIS
2 PerryLorier 5 __#include <sys/types.h>__
6 __#include <sys/ipc.h>__
7 __#include <sys/msg.h>__
8 __int msgget ( key_t__ ''key''__, int__ ''msgflg'' __)__
1 perry 9
10 !!DESCRIPTION
2 PerryLorier 11 The function returns the message queue identifier associated to the value of the ''key'' argument. A new message queue is created if ''key'' has value __IPC_PRIVATE__ or
12 ''key'' isn't __IPC_PRIVATE__, no existing message queue is associated to ''key'', and __IPC_CREAT__ is asserted in ''msgflg'' (i.e.
13 ''msgflg''____''IPC_CREAT'' is nonzero). The presence in ''msgflg'' of the fields __IPC_CREAT__ and __IPC_EXCL__ plays the same role, with respect to the
14 existence of the message queue, as the presence of __O_CREAT__ and __O_EXCL__ in the mode argument of the open(2) system call: i.e. the __msgget__ function
15 fails if ''msgflg'' asserts both __IPC_CREAT__ and __IPC_EXCL__ and a message queue already exists for ''key''.
1 perry 16
2 PerryLorier 17 Upon creation, the lower 9 bits of the argument ''msgflg'' define the access permissions of the message queue. These permission bits have the same format and semantics as the access permissions parameter in open(2) or creat(2) system calls. (The execute permissions are not used.)
1 perry 18
2 PerryLorier 19 Furthermore, while creating, the system call initializes the system message queue data structure __msqid_ds__ as follows:
1 perry 20
2 PerryLorier 21 __msg_perm.cuid__ and __msg_perm.uid__ are set to the effective user-ID of the calling process.
1 perry 22
2 PerryLorier 23 __msg_perm.cgid__ and __msg_perm.gid__ are set to the effective group-ID of the calling process.
1 perry 24
2 PerryLorier 25 The lowest order 9 bits of __msg_perm.mode__ are set to the lowest order 9 bit of ''msgflg''.
1 perry 26
2 PerryLorier 27 __msg_qnum__, __msg_lspid__, __msg_lrpid__, __msg_stime__ and __msg_rtime__ are set to 0.
1 perry 28
29 __msg_ctime__ is set to the current time.
30
2 PerryLorier 31 __msg_qbytes__ is set to the system limit __MSGMNB__.
1 perry 32
2 PerryLorier 33 If the message queue already exists the access permissions are verified, and a check is made to see if it is marked for
34 destruction.
1 perry 35
36 !!RETURN VALUE
2 PerryLorier 37 If successful, the return value will be the message queue identifier (a nonnegative integer), otherwise __-1__ with __errno__ indicating the error.
1 perry 38
39 !!ERRORS
40
2 PerryLorier 41 For a failing return, __errno__ will be set to one among the following values:
1 perry 42
2 PerryLorier 43 ;[EACCES]: A message queue exists for ''key'', but the calling process has no access permissions to the queue.
44 ;[EEXIST]: A message queue exists for __key__ and ''msgflg'' was asserting both __IPC_CREAT__ and __IPC_EXCL__.
45 ;[EIDRM]: The message queue is marked for removal.
46 ;[ENOENT]: No message queue exists for ''key'' and ''msgflg'' wasn't asserting __IPC_CREAT__.
47 ;[ENOMEM]: A message queue has to be created but the system has not enough memory for the new data structure.
48 ;[ENOSPC]: A message queue has to be created but the system limit for the maximum number of message queues (__MSGMNI__) would be exceeded.
1 perry 49
50 !!NOTES
2 PerryLorier 51 __IPC_PRIVATE__ isn't a flag field but a __key_t__ type. If this special value is used for ''key'', the system call ignores everything but the lowest order 9 bits
52 of ''msgflg'' and creates a new message queue (on success).
1 perry 53
2 PerryLorier 54 The following is a system limit on message queue resources affecting a __msgget__ call:
55 ;__MSGMNI__: System wide maximum number of message queues: policy dependent.
1 perry 56
57 !!BUGS
2 PerryLorier 58 Use of __IPC_PRIVATE__ does not actually prohibit other processes from getting access to the allocated message queue.
1 perry 59
2 PerryLorier 60 As for the files, there is currently no intrinsic way for a process to ensure exclusive access to a message queue. Asserting both __IPC_CREAT__ and __IPC_EXCL__ in
61 ''msgflg'' only ensures (on success) that a new message queue will be created, it doesn't imply exclusive access to the message queue.
1 perry 62
63 !!CONFORMING TO
2 PerryLorier 64 SVr4, SVID. SVr4 does not document the [EIDRM] error code.
1 perry 65
66 !!SEE ALSO
2 PerryLorier 67 ftok(3), ipc(5), msgctl(2), msgsnd(2), msgrcv(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 9 times)