免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 875 | 回复: 2
打印 上一主题 下一主题

斑竹帮忙!系统调用权限如何设置(已解决) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-10-17 22:29 |只看该作者 |倒序浏览
我写的消息通信列程,用到了信号量,消息队列,共享存储等系统调用,在gcc 3.3.2中编译通过,在root帐户下运行正常,在其他如bin,sys,adm,daemon,等组权限下均不能正常初始化,请问那位大哥能帮忙解决!这程序是基于系统v的消息通信编写的,在hp-unix,AIX,下都可以运行!我的系统是solaris 9 x86
拜托

论坛徽章:
0
2 [报告]
发表于 2004-10-17 22:59 |只看该作者

斑竹帮忙!系统调用权限如何设置(已解决)

int main(void)
{
    pid_t pid;  /*pid*/
    int mqid;/*msqid*/
    struct msqid_ds buf;
    pid=getpid();
    if ((mqid = msgget(pid, IPC_CREAT|IPC_EXCL|PERMS)) == -1)
        printf("can't creat!\n";
    else
        printf("creat ok!\n";
        
    if (msgctl (mqid, IPC_STAT, &buf) < 0)
        printf("can't control!\n";
    else
        printf("control ok!\n";
   buf.msg_qbytes = 20000; /* set buffer len */
   if (msgctl (mqid, IPC_SET, &buf) <0)//这句没法在普通帐户下执行
        printf("can't control 1!\n";
    else
        printf("control 1 ok!\n";
}/*End Main*/

论坛徽章:
0
3 [报告]
发表于 2004-10-17 23:18 |只看该作者

斑竹帮忙!系统调用权限如何设置(已解决)

int main(void)
{
    pid_t pid;  /*pid*/
    int mqid;/*msqid*/
    struct msqid_ds buf;
    pid=getpid();
    if ((mqid = msgget(pid, IPC_CREAT|IPC_EXCL|PERMS)) == -1)
        printf("can't creat!\n";
    else
        printf("creat ok!\n";
        
    if (msgctl (mqid, IPC_STAT, &buf) < 0)
        printf("can't control!\n";
    else
        printf("control ok!\n";
        
   printf("%d",buf.msg_qbytes);/*default  qbytes=4096*/
   buf.msg_qbytes = 20000; /* set buffer len */
   if (msgctl (mqid, IPC_SET, &buf) <0)/*设置出错*/
        printf("can't control 1!\n";
    else
        printf("control 1 ok!\n";
}/*End Main*/
请教怎么设置系统的默认值,初始4096,应用需要更大!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP