我的 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/