看看这个semaphore出了什么问题?

wabc 2003-09-02 02:51:10
mysem_put = sem_open( "mysem_put0" , O_RDWR|O_CREAT , S_IRUSR|S_IWUSR , 1);

运行上面的代码时返回错误:EINVAL
在solaris 8 上
...全文
60 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wabc 2003-09-03
  • 打赏
  • 举报
回复
thanks.
by the way,where can I find(or download) the POSIX specification?
fierygnu 2003-09-03
  • 打赏
  • 举报
回复
http://www.opengroup.org/onlinepubs/007904975/
fierygnu 2003-09-02
  • 打赏
  • 举报
回复
sem_open不会建立文件,与根目录也没有什么关系。
下面是POSIX标准对sem_open的name参数的解释:
If name begins with the slash character, then processes calling sem_open() with the same value of name shall refer to the same semaphore object, as long as that name has not been removed. If name does not begin with the slash character, the effect is implementation-defined. The interpretation of slash characters other than the leading slash character in name is implementation-defined.
wabc 2003-09-02
  • 打赏
  • 举报
回复
"/mysem_put0"是不是要在根目录下建立一个这样的文件?
fierygnu 2003-09-02
  • 打赏
  • 举报
回复
mysem_put = sem_open( "/mysem_put0" , O_RDWR|O_CREAT , S_IRUSR|S_IWUSR , 1);
名字必须以"/"开头。

23,115

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧