Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello!

I'm trying to use the mkfifo function from the POSIX module. I'm seeing inconsitencies with how it implements the 'mode' portion of the command.

If I use a mode of 0444 or 0555, then mkfifo behaves exactly as expected - the pipe is create with perms of 0444 or 055. However, if I use mkfifo with a mode of 0666 or 0777, then it doesn't work as expected.

Using a mode of 0666 actually creates a pipe with 0644. Using a mode of 0777 creates a pipe with 0755.

Is this a bug? Or is it just some behaviour that I don't understand?

Below is an illustration of what I'm seeing.

Perl version 5.8.8 on Kubuntu linux.

Thanks!

hmcm@helen:~$ perl -e 'use POSIX; mkfifo("four", 0444);' hmcm@helen:~$ ls -l four pr--r--r-- 1 hmcm hmcm 0 2007-10-25 13:33 four hmcm@helen:~$ perl -e 'use POSIX; mkfifo("five", 0555);' hmcm@helen:~$ ls -l five pr-xr-xr-x 1 hmcm hmcm 0 2007-10-25 13:34 five hmcm@helen:~$ perl -e 'use POSIX; mkfifo("six", 0666);' hmcm@helen:~$ ls -l six prw-r--r-- 1 hmcm hmcm 0 2007-10-25 13:35 six hmcm@helen:~$ perl -e 'use POSIX; mkfifo("seven", 0777);' hmcm@helen:~$ ls -l seven prwxr-xr-x 1 hmcm hmcm 0 2007-10-25 13:36 seven

Replies are listed 'Best First'.
Re: bug in POSIX mkfifo?
by Joost (Canon) on Oct 25, 2007 at 11:49 UTC
Re: bug in POSIX mkfifo?
by KurtSchwind (Chaplain) on Oct 25, 2007 at 13:26 UTC
    I agree. From the posix man page on mkfifo:

    set file permission bits to MODE, not a=rw - umask


    It doesn't look like a bug. You just need to be aware of your umask.