messctrl.c

来自「在进行linux服务器编程时经常要用到消息队列编程,但直接使用系统调用可能还不能」· C语言 代码 · 共 46 行

C
46
字号
#include <stdio.h>#include<stdlib.h>#include<dirent.h>#include<sys/msg.h>#include<sys/ipc.h>#include<sys/types.h>#include <mysql/mysql.h>#include <time.h>#define QUEUE_SO 0x7333L#define PERMS 0666typedef struct{        long mtype;        unsigned char mdata[8192];} my_msg;main(){	char str[128];	int i,j,k;	int pid;	int proc[5000];	int mm,qo,qo1,len;	DIR *dirp;	struct dirent *direntp;	my_msg msg_buf;	struct msqid_ds msqid_sys;	write_log("Start Message Queue Control......");	if ((qo = msgget (QUEUE_SO, PERMS | IPC_CREAT)) < 0)      	 {             	  write_log("get message queue error");                exit(0);        }	if((pid=fork())==-1)	{		write_log("Fork child error!\n");		exit(0);	}	if(pid)		exit(0);	//parent exit	while(1){		dirp=opendir("/proc");		j=0;		k=0;		while((direntp = readdir(dirp)) != NULL) //莉

⌨️ 快捷键说明

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