IPC - msg

[dss@SICT ~]$ cat msg.c #include #include #include #include #include #include typedef struct msgbuftag{ long mtype; char mtext[1]; } mymsgbuf ; int main() { int msqid; struct msqid_ds info; mymsgbuf buf ; msqid = msgget(IPC_PRIVATE,IPC_CREAT|0666); //没有权限的话,会有问题。 printf("msqid: %d /n",msqid); buf.mtype= 1; buf.mtext[0] = 10; msgsnd(msqid,&buf,sizeof(buf),0); msgctl(msqid,IPC_STAT,&info); printf("read_write: %03o,cbytes= %lu,qnum=%lu,qbytes=%lu/n",info.msg_perm.mode&0x777,(long)info.msg_cbytes,(long)info.msg_qnum,(long)info.msg_qbytes); system("ipcs -q"); msgctl(msqid,IPC_RMID,NULL); exit(0); }

你可能感兴趣的:(struct,null,System)