问题:
sem_open will failed with "No such file or directory"

 
解释1:
这是由于在Linux内核中,创建信号量的默认路径是/dev/shm。当你要创建一个信号量/tmp/mysem时,实际上是创建了一个/dev/shm /sem.tmp/mysem,而这里由于/dev/shm/tmp目录根本就不存在,所以会出错。
解决方法:
    *直接写信号量文件的名字或宏定义不带路径,将会创建在/dev/shm中:sem_open("mysem", ...) 
 
解释2:
 
If define name as "/tmp/xxxx", and invoke sem_open(name, flag...), sem_open will failed with "No such file or directory". 
Looked into the code sem_open.c, the reason is that the name ("/tmp/xxxx")will map to /dev/shm/sem.tmp/xxxx, but sem.tmp directory is not there, so there will be an error.
I think in sem_open.c, it maybe needs a check of whether name has more slash characters other than the leading slash character.
If it has, mkdir the related directory before rename operation (sem_open.c:234), such as the following:
  1. tmpname = strrchr(finalname,'/');// get the file name without directory
  2. strncpy(pathname, finalname, strlen(finalname)- strlen(tmpname));// get the directory path
  3. mkdir(pathname,0777)
To the POSIX std, it says the interpretation of slash characters other than the leading slash character in name is implementaion defined. I think it will be more friendly to allow the user using a name with directory.

sem_open中信号量命名的更多相关文章

  1. Linux有名信号量的创建(sem_open中name参数构造)【转】

    转自:http://blog.csdn.net/gfeng168/article/details/40740865 版权声明:本文为博主原创文章,未经博主允许不得转载. 一.sem_open函数nam ...

  2. Linux中信号量处理

    参考文章: http://blog.csdn.net/qinxiongxu/article/details/7830537/ 信号量一. 什么是信号量信号量的使用主要是用来保护共享资源,使得资源在一个 ...

  3. iOS开发(OC)中的命名规范

    开小差:最近发现自己有一个经验主义的毛病,不太容易接受新的知识,这对从事技术研发的人来说不太合理,需要改之. 正文:通过读写大量代码我有自己的一套编程思路和习惯,自认为自己的编码习惯还是不错的,代码结 ...

  4. iOS 在 Xcode 中重命名项目名称

    本教程使用的 Xcode 版本是Xcode 6.3.1,网上有好多的教程,都是在 Xcode 4 上做的讲解,现以本文章讲解一下如何在 Xcode 6.3.1 中重命名你的项目名称,包括你的应用名称. ...

  5. C#中使用命名管道进行进程通信的实例

    原文:C#中使用命名管道进行进程通信的实例 1 新建解决方案NamedPipeExample 在解决方案下面新建两个项目:Client和Server,两者的输出类型均为"Windows 应用 ...

  6. kvm中重命名虚拟机

    kvm中重命名虚拟机 1.查看虚拟机 [root@linux ~]# virsh list --all Id Name State ---------------------------------- ...

  7. ucos中信号量 事件标志 消息队列都怎么用

    信号量 事件标志和消息队列分别应用于什么场景(反正我学的时候有点闹不清,现在总结一下): 信号量和事件标志用于任务同步.详细来说,这个功能可以替代以前裸机中你打一个标记的功能,比如使用了一个定时器,5 ...

  8. Sitecore CMS中如何命名项目名称

    如何在Sitecore CMS中命名项目,以及配置命名限制,“显示名称”是什么以及如何使用它. 任何其他名称的项目 当创建Sitecore的项目,内容编辑器要求制作者为新建项目提供名称.输入的名称将其 ...

  9. CSS那些事!这个篇幅是我特意开的,不是因为帮助小菜之类的,而是在多人的团队配合中各种命名冲突的规范让人蛋疼

    CSS那些事!这个篇幅是我特意开的,不是因为帮助小菜之类的,而是在多人的团队配合中各种命名冲突的规范让人蛋疼. css这个东西只要不是新的离谱都会写,但是每个人的命名风格,方法,都不同 有人喜欢驼峰, ...

随机推荐

  1. 【题解】CF1154

    A Description 有三个正整数 \(a,~b,~c\),现在给定 \(x_1~=~a + b,~x_2~=~a + c, x_3~=~b + c, ~x_4~=~a + b + c\),请求 ...

  2. EMF的安装及用例

    转: EMF的安装及用例 本人正在开发专门针对计算机视觉领域的DSL(这是一个和某公司合作的项目),欢迎各位朋友一起交流学习! 一.简介 EMF是一个建模框架和代码生成工具,用于构建基于结构化数据模型 ...

  3. poj 3294 后缀数组 多字符串中不小于 k 个字符串中的最长子串

    Life Forms Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 16223   Accepted: 4763 Descr ...

  4. 在VC6/VC2005下使程序直接具有XP风格(XP Style):

    原文 首先将以下文本保存为XpStyle.mainfest(后经实践,文件名和后缀是什么都无所谓) <?xml version="1.0" encoding="UT ...

  5. GO_09:GO语言基础之reflect反射

    反射reflection 1. 反射可以大大的提高程序的灵活性,使得 interface{} 有更大的发挥余地 2. 反射使用 TypeOf 和 ValueOf 函数从接口中获取目标对象信息 3. 反 ...

  6. jquery.lazyload插件实现图片延迟加载详解

    什么是LazyLoad技术? 在页面上图片比较多的时候,打开一张页面必然引起与服务器大数据量的交互.尤其是对于高清晰的图片,占了几百K的空间.Lazy Load 是一个用 JavaScript 编写的 ...

  7. centos7 install python3.7 with problem and how to fix it.

    问题如下: configure: error: no acceptable C compiler found in $PATH 缺少gcc zipimport.ZipImportError: can’ ...

  8. COGS 栅格网络流

    750. 栅格网络流 http://www.cogs.pro/cogs/problem/problem.php?pid=750 ★★☆   输入文件:flowa.in   输出文件:flowa.out ...

  9. 动态规划:POJ No 2385 Apple Catching

    #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> ...

  10. [转载]Visual Studio支持Node.js

    http://news.cnblogs.com/n/193893/ https://nodejstools.codeplex.com/ 微软发布了一个官方插件“Node.js Tools for Vi ...