Mkfifo file permissions do not execute correctly

The next line in my C program should contain read / write permissions for All / Group / Owner

mkfifo("/tmp/dumbPipe", 0666) 

But as soon as I ran the code and checked the resolution, but the recording bits were not written, I end up with

 prw-r--r-- 

The owners are the same, is this a problem as I create a channel in the tmp directory? When I run chmod 666 from the cmd line, all permissions are set correctly.

+6
c unix named-pipes permissions
source share
2 answers

This post is without comment, simply quoting manuals. Brievity etc.

Quote from man 3 mkfifo:

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

Quote from man 2 umask

The typical default value for the umask process is S_IWGRP | S_IWOTH (octal 022). In the usual case, when the mode open (2) argument 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; ie, rw-r--r--). 
+9
source share

Sala, I know it's late, but for other users I prefer to write this comment. Even if you are definitely 0666 as permission, you should know that there is another factor called "creating a process file mode", so the question is:

How to change the current process file mode creation?

Answer: use umask (permission) at the beginning of your program - and give 0000 as permission

http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html

this should help.

0
source share

All Articles