mkq.c

来自「基于网络编程的例子」· C语言 代码 · 共 34 行

C
34
字号
/* * mkq.c - Create a SysV IPC message queue */#include <sys/types.h>#include <sys/ipc.h>#include <sys/msg.h>#include <stdio.h>#include <stdlib.h>int main(int argc, char *argv[]){    int qid; /* The queue identifier */    key_t key; /* The queue key */    key = 123;    /* Create the queue */    if((qid = msgget(key, IPC_CREAT | 0666)) < 0) {        perror("msgget:create");        exit(EXIT_FAILURE);    }    printf("created queue id = %d\n", qid);         /* Open the queue again */    if((qid == msgget(key, 0)) < 0) {        perror("msgget:open");        exit(EXIT_FAILURE);    }    printf("opened queue id = %d\n", qid);    exit(EXIT_SUCCESS);}     

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?