msgget(2) System Calls Manual msgget(2) NOMBRE msgget - devuelve un identificador System V para una cola de mensajes BIBLIOTECA Biblioteca Estandar C (libc, -lc) SINOPSIS #include int msgget(key_t key, int msgflg); DESCRIPCION The msgget() system call returns the System V message queue identifier associated with the value of the key argument. It may be used either to obtain the identifier of a previously created message queue (when msgflg is zero and key does not have the value IPC_PRIVATE), or to create a new set. A new message queue is created if key has the value IPC_PRIVATE or key isn't IPC_PRIVATE, no message queue with the given key key exists, and IPC_CREAT is specified in msgflg. If msgflg specifies both IPC_CREAT and IPC_EXCL and a message queue already exists for key, then msgget() fails with errno set to EEXIST. (This is analogous to the effect of the combination O_CREAT | O_EXCL for open(2).) Upon creation, the least significant bits of the argument msgflg define the permissions of the message queue. These permission bits have the same format and semantics as the permissions specified for the mode argument of open(2). (The execute permissions are not used.) Si se crea una nueva cola de mensajes, la llamada al sistema inicializa la estructura de datos del sistema (consulte msgctl(2)) para la cola msqid_ds como se muestra: o msg_perm.cuid y msg_perm.uid son fijados al identificador del usuario efectivo del proceso invocador. o msg_perm.cgid y msg_perm.gid son fijados al identificador de grupo efectivo del proveso invocador. o Los 9 bits menos importantes de msg_perm.mode son fijados a los 9 bits menos significativos de msgflg. o msg_qnum, msg_lspid, msg_lrpid, msg_stime y msg_rtime son puestos a 0. o msg_ctime contendra la hora actual. o msg_qbytes sera igual al limite impuesto por el sistema MSGMNB. Si la cola de mensajes ya existe, se verifican los permisos, y ser realiza una comprobacion a fin de verificar si esta marcada para su destruccion. VALOR DEVUELTO On success, msgget() returns the message queue identifier (a nonnegative integer). On failure, -1 is returned, and errno is set to indicate the error. ERRORES EACCES A message queue exists for key, but the calling process does not have permission to access the queue, and does not have the CAP_IPC_OWNER capability in the user namespace that governs its IPC namespace. EEXIST IPC_CREAT and IPC_EXCL were specified in msgflg, but a message queue already exists for key. ENOENT No message queue exists for key and msgflg did not specify IPC_CREAT. ENOMEM Una cola de mensajes ha de ser creada pero el sistema no contiene suficiente memoria para la nueva estructura de datos. ENOSPC Una cola de mensajes ha de ser creada pero el limite del sistema para el maximo numero de colas de mensajes (MSGMNI) sera superado. ESTANDARES POSIX.1-2008. HISTORIAL POSIX.1-2001, SVr4. Linux Until Linux 2.3.20, Linux would return EIDRM for a msgget() on a message queue scheduled for deletion. NOTAS 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 least significant 9 bits of msgflg and creates a new message queue (on success). Lo siguiente es una limitacion en los recursos del sistema que afecta a la llamada msgget(): MSGMNI System-wide limit on the number of message queues. Before Linux 3.19, the default value for this limit was calculated using a formula based on available system memory. Since Linux 3.19, the default value is 32,000. On Linux, this limit can be read and modified via /proc/sys/kernel/msgmni. ERRORES La eleccion del nombre IPC_PRIVATE puede que fuera desafortunada, IPC_NEW mostraria mas claramente su funcion. VEASE TAMBIEN msgctl(2), msgrcv(2), msgsnd(2), ftok(3), capabilities(7), mq_overview(7), sysvipc(7) TRADUCCION La traduccion al espanol de esta pagina del manual fue creada por Juan Piernas y Marcos Fouces Esta traduccion es documentacion libre; lea la GNU General Public License Version 3 o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. Si encuentra algun error en la traduccion de esta pagina del manual, envie un correo electronico a . Paginas de manual de Linux 6.06 31 Octubre 2023 msgget(2)