gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 17:20:20 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com