Timeline for How does a FIFO (named pipe) differs from a regular pipe (unnamed pipe)?
Current License: CC BY-SA 3.0
19 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 12, 2018 at 13:14 | history | edited | Toby Speight | CC BY-SA 3.0 | Fixed a couple of typos; minor tweaks to the markdown |
| Apr 11, 2018 at 16:54 | vote | accept | Arcticooling | ||
| Apr 11, 2018 at 16:50 | comment | added | derobert | @user9303970 Added two more footnotes for you. | |
| Apr 11, 2018 at 16:50 | history | edited | derobert | CC BY-SA 3.0 | add footnote about grep reading from terminal; add footnote about pipefs |
| Apr 11, 2018 at 16:45 | history | edited | derobert | CC BY-SA 3.0 | add footnote about grep reading from terminal |
| Apr 11, 2018 at 16:42 | comment | added | derobert | @user9303970 FIFO is a name from its behavior: the first thing written ("first in") is the first thing read ("first out"). It's a somewhat odd name, though, since e.g., stream sockets work the same way, but aren't called FIFOs. | |
| Apr 11, 2018 at 16:40 | comment | added | derobert | @user9303970 I'm not sure if it'll help the unintuitiveness or just make it worse, but... remember that files themselves are just an abstraction provided by the kernel. The physical reality of charges in some capacitors (SSD), magnetized iron compounds (hard disk, tape), pits in a reflective layer (CD/DVD/BD), etc., don't actually know about files. Neither does the storage hardware above that. Files only exist once you have the kernel (or something else providing the abstraction) running. So it's not that weird to use the same abstraction for other things—If it acts like a file, it's a file. | |
| Apr 11, 2018 at 16:39 | comment | added | Arcticooling | Hmm @derobert maybe good to add a footnote. | |
| Apr 11, 2018 at 16:36 | comment | added | derobert | @user9303970 If you just type grep pattern, it'll be reading from the terminal as stdin. Usually not that useful (maybe if you're going to paste something to the terminal). | |
| Apr 11, 2018 at 16:34 | comment | added | derobert | @DavidFoerster thank you, I think I've fixed that and now consistently use syscall names. | |
| Apr 11, 2018 at 16:33 | history | edited | derobert | CC BY-SA 3.0 | Consistently use syscall names, thanks @DavidFoerster. |
| Apr 11, 2018 at 12:03 | comment | added | David Foerster | You're using system call names in the first part of your answer and then switch to (common) applications names (rm) in the second. Wouldn't it be more consistent to refer to unlink instead since that is also what the kernel does to the file? That would also work out better for grammar: “rm’d” vs. unlinked. | |
| Apr 11, 2018 at 9:34 | comment | added | Arcticooling | Also, would you say the name "FIFO" is misleading when used just for a named pipe? | |
| Apr 11, 2018 at 9:34 | review | Suggested edits | |||
| Apr 11, 2018 at 10:02 | |||||
| Apr 11, 2018 at 9:32 | comment | added | Arcticooling | Also, of course a pipe is a file, but it is so unintuitive to a newbiew like myself to think of it as a file. I do get the notion that it is first just part of a command, but when Bash interpret the command, it is a file created somewhere: If it is a regular pipe, it is a temporary file, if it is a named pipe (FIFO) it is much less temporary. I edited the answer to add: When typing a command, both pipes are just syntax but when the shell interpret the command, they are both files. A regular pipe is temporary, and a named pipe ("FIFO") is permanent, at least by definition. | |
| Apr 11, 2018 at 9:22 | comment | added | Arcticooling | Grep doesn't really care¹ that it's reading from a pipe instead of a terminal, what is greap reading from terminal? Never came across such need, and thanks for the answer. | |
| Apr 11, 2018 at 0:00 | comment | added | derobert | @PeterCordes yep, that'd be one of those optimizations (if it actually were more optimal). There are no doubt others, like reading in large chunks or maybe someone even has a multithreaded grep. | |
| Apr 10, 2018 at 23:53 | comment | added | Peter Cordes | Some grep implementations have an option to mmap input files if possible, instead of read()ing. (GNU grep no longer has such an option, if it ever did, because it's usually not a performance win these days.) This is of course only possible for regular file and block devices, not anonymous or named pipes. Most grep implementations would want to seek in their input, but if stdin is a regular file, it's seekable. This matters for stuff like a video file: cat foo.mkv | mpv - vs. <foo.mkv mpv -. The latter will notice that stdin is seekable and take advantage. | |
| Apr 10, 2018 at 23:11 | history | answered | derobert | CC BY-SA 3.0 |