views:

252

answers:

1

The following line in my C program should provided All/Group/Owner read and write permissions

mkfifo("/tmp/dumbPipe", 0666)

But once I execute the code and check out the permission non of the write bits were set, I end up with

prw-r--r--

The owners are the same, Is it a problem since I'm creating the pipe in the tmp directory? When I run chmod 666 from the cmd line all the permissions get set correctly.

+4  A: 

This is a no-comments post, just quoting manuals. Brievity etc.

Quote from man 3 mkfifo:

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

Quote from 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--).
Pavel Shved