当前位置: 技术问答>linux和unix
进程通信问题?
来源: 互联网 发布时间:2015-04-13
本文导语: 初始化 Key =ftok(ApplicationPath,0); shmOrMsgID=msgget(Key,IPC_CREAT|666); 运行的时候 MsgBuffer.ArithmeticsAddr=new TMinGiniIndexTree(ModelType,tResultList,tMsgList,tModelList,MinClassifyData,RunShowMessage); #ifdef __MSGQUEUES re...
初始化
Key =ftok(ApplicationPath,0);
shmOrMsgID=msgget(Key,IPC_CREAT|666);
运行的时候
MsgBuffer.ArithmeticsAddr=new TMinGiniIndexTree(ModelType,tResultList,tMsgList,tModelList,MinClassifyData,RunShowMessage);
#ifdef __MSGQUEUES
retvalues=msgsnd(shmOrMsgID,&MsgBuffer,sizeof(MsgBuffer.ArithmeticsAddr),IPC_NOWAIT);
printf("send msg shmOrMsgID=%d,Size=%d retvalues=%dn",shmOrMsgID,sizeof(MsgBuffer.ArithmeticsAddr),retvalues);
#endif
#ifdef __PRINTMSG
printf("TMinGiniIndexTree=%pn",MsgBuffer.ArithmeticsAddr);
#endif
Result=((TMinGiniIndexTree *)MsgBuffer.ArithmeticsAddr)->Run();
#ifdef __MSGQUEUES
retvalues=msgrcv(shmOrMsgID,&MsgBuffer,sizeof (MsgBuffer.ArithmeticsAddr),1,IPC_NOWAIT|MSG_NOERROR);
if (retvalues==-1){
printf("shmOrMsgID=%dn",shmOrMsgID);
perror("errno");
}
else printf("msgrcv OKn");
#endif
为什么会提示。。errno: Permission denied
谢谢
Key =ftok(ApplicationPath,0);
shmOrMsgID=msgget(Key,IPC_CREAT|666);
运行的时候
MsgBuffer.ArithmeticsAddr=new TMinGiniIndexTree(ModelType,tResultList,tMsgList,tModelList,MinClassifyData,RunShowMessage);
#ifdef __MSGQUEUES
retvalues=msgsnd(shmOrMsgID,&MsgBuffer,sizeof(MsgBuffer.ArithmeticsAddr),IPC_NOWAIT);
printf("send msg shmOrMsgID=%d,Size=%d retvalues=%dn",shmOrMsgID,sizeof(MsgBuffer.ArithmeticsAddr),retvalues);
#endif
#ifdef __PRINTMSG
printf("TMinGiniIndexTree=%pn",MsgBuffer.ArithmeticsAddr);
#endif
Result=((TMinGiniIndexTree *)MsgBuffer.ArithmeticsAddr)->Run();
#ifdef __MSGQUEUES
retvalues=msgrcv(shmOrMsgID,&MsgBuffer,sizeof (MsgBuffer.ArithmeticsAddr),1,IPC_NOWAIT|MSG_NOERROR);
if (retvalues==-1){
printf("shmOrMsgID=%dn",shmOrMsgID);
perror("errno");
}
else printf("msgrcv OKn");
#endif
为什么会提示。。errno: Permission denied
谢谢
|
shmOrMsgID=msgget(Key,IPC_CREAT|666);
// 在 666 前应该加 0 变成 0666。
// 数字前以 0 开头表示八进制
// 在 666 前应该加 0 变成 0666。
// 数字前以 0 开头表示八进制