⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msgctl.c

📁 scounix编译通过,c/s完整实现
💻 C
字号:
/*
*./msgctl.c
*make message queue with keys and mode given as inputs.
*/
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#define	SVMSG_MODE	(MSG_R|MSG_W|MSG_R>>3|MSG_R>>6)

main()
{
	int msgid ;
	struct msqid_ds info;
	struct msgbuf{
		int mtype ;
		char  mtext[1] ;
	}buf ;

	msgid = msgget(IPC_PRIVATE, SVMSG_MODE|IPC_CREAT) ; 
	
	buf.mtype = 1;
	buf.mtext[0] = 1;
	printf("msgid = %d\n",msgid);
	msgsnd(msgid, &buf, 1,0);

	msgctl(msgid, IPC_STAT, &info);
	printf("read-write:%03o,cbytes = %lu, qunm = %lu, qbytes = %lu\n",\
		info.msg_perm.mode&0777, (ulong_t)info.msg_cbytes, \
		(ulong_t)info.msg_qnum, (ulong_t)info.msg_qbytes);
	system("ipcs -q");
	msgctl(msgid, IPC_RMID, NULL);
	exit(0);
}

⌨️ 快捷键说明

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