6

I have a named fifo created from a C program like this:

res = mkfifo("/home/myfolder/myfifo", 0666);

after that there are only reads and writes.

Now, from this answer : Does a named pipe change the filesystem I concluded that the system should practically never actually write in the actual file on the filesystem, and that everything is handled in RAM.

Whenever I restart my program, the "mkfifo" line returns a "File already exists" error, which is OK.
What bothers me is that when I "ls" the file, the "last modified date time" sometimes does change. If the system never actually writes into the file, shouldn't it remain constant?

2
  • 1
    I hate to edit code examples in questions... but I presume you actually have the required double-quotes (") in your C program? And the mode?
    – derobert
    Commented Dec 4, 2014 at 22:43
  • Yeah, sorry about that and thanks for the edit. The question's focus was on effects of the code. Thus I thought it was obvious that the code compiles and runs. Thanks anyway.
    – Nitkov
    Commented Dec 5, 2014 at 10:16

1 Answer 1

8

The data passing through the pipe is not written or read to and from the filesystem. When creating the named pipe an inode is allocated so that it can be linked to from the directory you created it in; so that's a form of "modifying the filesystem".

Accessing the named pipe will update the inode's access time, writing to the named pipe will update the inode's modification time, so in that indirect way the filesystem is also being modified. That doesn't mean that the data is written to the filesystem; it's just how Linux handles writes to a named pipe.

2
  • Tested this by setting the files to read only. I was able to use the pipes and the modification time changed. Guess that proves your answer. Can't upvote yet though.
    – Nitkov
    Commented Dec 4, 2014 at 11:19
  • I have just performed a test and, interestingly, just reading or just writing to a named pipe does not update its modification time. It is only when both reading and writing (or writing and reading) are performed that the modification time gets updated.
    – The Quark
    Commented Oct 30, 2021 at 12:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .