首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

这么简单的sem_int竟然失败,该怎么解决

2012-02-12 
这么简单的sem_int竟然失败/*testSemp文件内容如下*/#includesemaphore.hstaticsem_tsemValintmain(){i

这么简单的sem_int竟然失败
/*testSemp文件内容如下*/
#include   <semaphore.h>

static   sem_t   semVal;
int   main()
{
          int   nVal;
          sem_init(&semVal,0,nVal);
          return   1;
}

g++   -o   testSemp   testSemp.cpp   //没有问题
./testSemp       //竟然报Bad   system   call(core   dumped)

我是在freebsd上跑的,哪位大哥碰到过?

[解决办法]
ERRORS
The sem_init() function will fail if:
[EINVAL]
The value argument exceeds SEM_VALUE_MAX.
[ENOSPC]
A resource required to initialise the semaphore has been exhausted, or the limit on semaphores (SEM_NSEMS_MAX) has been reached.
[ENOSYS]
The function sem_init() is not supported by this implementation.
[EPERM]
The process lacks the appropriate privileges to initialise the semaphore.
[解决办法]
是否是nVal 没有初始化阿, 你试试 int nVal=0; 看看
[解决办法]
问题不清楚, 我手头没UNIX, 没法给你试试.

热点排行