c - mkfifo 文件权限未正确执行

标签 c unix permissions named-pipes

我的 C 程序中的以下行应提供 All/Group/Owner 读写权限

mkfifo("/tmp/dumbPipe", 0666)

但是一旦我执行了代码并检查了未设置写入位的权限,我最终得到了

prw-r--r-- 

所有者是相同的,这是一个问题,因为我在 tmp 目录中创建管道吗?当我从 cmd 行运行 chmod 666 时,所有权限都已正确设置。

最佳答案

这是一个没有评论的帖子,只是引用手册。简洁等

引自 man 3 mkfifo:

It is modified by the process's umask in the usual way: the permissions of the created file are (mode & ~umask).

引自 man 2 umask

The typical default value for the process umask is S_IWGRP | S_IWOTH (octal 022). In the usual case where the mode argument to open(2) is specified as:

      S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH

  (octal 0666) when creating a new file, the permissions on the resulting file will be:

      S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH

  (because 0666 & ~022 = 0644; i.e., rw-r--r--).

关于c - mkfifo 文件权限未正确执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1343144/

相关文章:

c - 解析 CSV 文件问题

c - 运行 c 程序 - stdio.h 我从哪里得到它?

c - 我如何用 C 练习 Unix 编程?

linux -/var/www/html 的权限

linux - 尝试在 ubuntu 20.04 上安装 vue/cli 时权限被拒绝

c - 读取输入的txt文件并用c格式化

c++ - 在包装 C 库的 C++ 类中放入什么?

c - 后缀表达式 (type-name){initializer-list}

Node.js 永远模块 - 获取正在运行的脚本的路径?

javascript - 避免从其他网站加载我的 js/css 文件