mkfifo 文件权限未正确执行
我的 C 程序中的以下行应提供“所有/组/所有者”读写权限,
mkfifo("/tmp/dumbPipe", 0666)
但是一旦我执行代码并检查未设置写入位的权限,我最终会得到“
prw-r--r--
所有者是相同的”,是吗?因为我在 tmp 目录中创建管道,所以出现问题?当我从 cmd 行运行 chmod 666 时,所有权限都得到正确设置。
The following line in my C program should provided All/Group/Owner read and write permissions
mkfifo("/tmp/dumbPipe", 0666)
But once I execute the code and check out the permission non of the write bits were set, I end up with
prw-r--r--
The owners are the same, Is it a problem since I'm creating the pipe in the tmp directory? When I run chmod 666 from the cmd line all the permissions get set correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一篇没有评论的帖子,只是引用手册。简洁等
引用自 man 3 mkfifo:
引自 man 2 umask
This is a no-comments post, just quoting manuals. Brievity etc.
Quote from man 3 mkfifo:
Quote from man 2 umask
萨拉姆,
我知道为时已晚,但对于其他用户,我选择写此评论
即使你精确的0666作为权限,你也应该知道还有一个因素叫做“进程的文件模式创建”,所以问题是:
如何更改当前进程文件模式的创建?
答案:在程序开头使用 umask(permission) - 并给予 0000 作为权限
http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html
这应该有帮助。
Salam,
I know it is to late but for other users I choose to write this comment
Even if you precise 0666 as permission, you should know that there is an another factor that is called " process's file mode creation ", so the question is :
how to change current process file mode creation ?
Answer : use umask(permission) at beginning of your program - and give 0000 as permission
http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html
this should help .