Why does open() create my file with the wrong permissions?

前端 未结 7 1708
天涯浪人
天涯浪人 2020-11-29 23:47

I am trying to read some text from a file and write it to another using open(), read() and write().

This is my open()

7条回答
  •  旧时难觅i
    2020-11-30 00:11

    Actually umask() only filters permissions and does not set them. The typical umask() value is 0002 ("don't give away write permission to the world") and if your mode value in the open( "file", O_CREAT, 0777) gave all permissions, the resulting file would have 775 as its permssions.

提交回复
热议问题