Questions tagged [fifo]

Questions about FIFO - first-in first-out special file, also known named pipe

Filter by
Sorted by
Tagged with
16 votes
3 answers
5k views

A virtual file containing the concatenation of other files

Is there a way of creating a filesystem object akin to this: mknod files p cat file1 file2 ... fileN > files but such that it can be seeked in, as if it were a regular file?
Witiko's user avatar
  • 781
11 votes
3 answers
2k views

What characterizes a file in Linux/Unix?

What characterizes a file in Linux/Unix? A file can have many types: regular file, directory, symlink, device file, socket, pipe, fifo, and more that I miss. For example, a symlink: $ sudo file /...
Tim's user avatar
  • 100k
21 votes
3 answers
77k views

continuous reading from named pipe (cat or tail -f)

I have configured rsyslog to log certain log events to /dev/xconsole: *.*;cron.!=info;mail.!=info |/dev/xconsole /dev/xconsole is a named pipe (fifo). If I want to see what is being logged, I ...
Martin Vegter's user avatar
3 votes
1 answer
9k views

What is the purpose of using a FIFO vs a temporary file or a pipe?

From APUE FIFOs can be used to duplicate an output stream in a series of shell commands. This prevents writing the data to an intermediate disk file (similar to using pipes to avoid intermediate ...
Tim's user avatar
  • 100k
2 votes
1 answer
327 views

Can FIFO or other thing not block on writer's access, and instead just drop data?

FIFO is problematic in use because both reader and writer have to open it – if one of them is being late, the other one is blocked inside the operating system. I have to implement a publishing ...
Digger's user avatar
  • 23
24 votes
3 answers
10k views

Prevent automatic EOFs to a named pipe, and send an EOF when I want it

I have a program that exits automatically upon reading an EOF in a given stream ( in the following case, stdin ). Now I want to make a shell script, which creates a named pipe and connect the program'...
iBug's user avatar
  • 3,468
15 votes
1 answer
8k views

How do I use inotify or named pipes over SSHFS?

Thanks sshfs magic, I can mount my home dir from a remote server with sshfs user@server:/home/user ~/remote Optimistically, I thought I'd set a local inotify-hook on ~/remote/logFile (in the sshfs ...
Anko's user avatar
  • 4,516
12 votes
3 answers
6k views

Named pipes, file descriptors and EOF

Two windows, same user, with bash prompts. In window-1 type: $ mkfifo f; exec <f So bash is now attempting to read from file descriptor 0, which is mapped to named pipe f. In window-2 type: $ ...
Fixee's user avatar
  • 1,901
5 votes
1 answer
174 views

Joined pipelines

Considering a routine such as this one: alpha() { echo a b c |tr ' ' '\n'; } which outputs a stream, I would like to take the output stream, transform it, and paste it with the original output ...
Petr Skocik's user avatar
  • 28.5k
55 votes
5 answers
41k views

Are FIFO, pipe & Unix domain socket the same thing in Linux kernel?

I heard that FIFOs are named pipes. And they have exactly the same semantics. On the other hand, I think Unix domain socket is quite similar to pipe (although I've never made use of it). So I wonder ...
Justin's user avatar
  • 713
15 votes
2 answers
11k views

How does a FIFO (named pipe) differs from a regular pipe (unnamed pipe)? [duplicate]

How does a FIFO (named pipe) differs from a regular pipe (|)? As I understand from Wikipedia, unlike a regular pipe, a FIFO pipe "keeps living" after the process has ended and can be deleted sometime ...
Arcticooling's user avatar
15 votes
2 answers
27k views

Under what conditions exactly does SIGPIPE happen?

Say we have a named pipe called fifo, and we're reading and writing to it from two different shells. Consider these two examples: shell 1$ echo foo > fifo <hangs> shell 2$ cat fifo foo shell ...
Naïm Favier's user avatar
8 votes
2 answers
4k views

How to cat named pipe without waiting

If there is nothing in a named pipe and I do: cat my_named_pipe it will wait until data arrives. Is there a flag I can use to exit immediately if there is no data to be read? Or perhaps a command ...
Alexander Mills's user avatar
8 votes
2 answers
7k views

Reading a named pipe: tail or cat?

I made a file descriptor using mkfifo fifo As soon as something is written to this pipe, I want to reuse it immediately. Should I use tail -f fifo or while true; do cat fifo; done ? They seem ...
phil294's user avatar
  • 895
4 votes
1 answer
4k views

Write to FIFO only if it exists

Most of the examples that I see about writing to a FIFO say to use the echo or cat commands and redirect stdout to the file. E.g., echo 'a' > /tmp/my_fifo However, this will create a regular file ...
Uyghur Lives Matter's user avatar
0 votes
1 answer
311 views

How to Pipe Segment of Heredoc Output to Local File

I am issuing a command to a remote device in order to run a tcpdump on one of it's interfaces, but capture the output to a local .pcap file on my Ubuntu VM. The command that I'm issuing is as follows: ...
Drew's user avatar
  • 23
12 votes
3 answers
7k views

Buffering (named) pipe in GNU OS

In the GNU OS a process can only write data to a pipe if another process reads the same data (from the same pipe) at the same time. Is there something like a pipe which lets the 1st process write and ...
Al Klimov's user avatar
  • 557
11 votes
2 answers
5k views

Linux named pipes: not as FIFO as thought

In short: mkfifo fifo; (echo a > fifo) &; (echo b > fifo) &; cat fifo What I expected: a b since the first echo … > fifo should be the first to have opened the file, so I expect ...
Marcus Müller's user avatar
9 votes
2 answers
13k views

Send EOF to named pipe - cleaning up / drying up fifo

If I have some random processes reading from a named pipe: tail -f MYNAMEDPIPED cat MYNAMEDPIPE | someOtherProc Elsewhere, I have a handle on MYNAMEDPIPED by name. is there a safe and clean way to ...
Alexander Mills's user avatar
9 votes
2 answers
16k views

Why does this script with a FIFO pipe not terminate?

This script: #!/bin/bash tmppipe=/tmp/temppipe mkfifo $tmppipe echo "test" > $tmppipe cat $tmppipe exit does not terminate. I assume that the cat command is waiting for an EOF from the ...
Benubird's user avatar
  • 5,822
8 votes
2 answers
3k views

Does named pipe modify the filesystem?

If I create a named pipe and then read/write on it, is the filesystem where the named pipe resides affected? I.e. is the data buffered on the filesystem until read, or does it reside in memory only?
michelemarcon's user avatar
8 votes
1 answer
8k views

Increase FIFO size limit

Thanks to the answers to my other question, I now understand that FIFO on Linux, i.e. /dev/xconsole has a buffer limit of 64 KB. How can I increase this limit to 128 KB? Apparently, I will need to ...
Martin Vegter's user avatar
7 votes
4 answers
4k views

How do I make systemd sockets close when service is stopped?

I'm currently trying to make a systemd service with two Fifo sockets. These sockets map to stdout and stdin of the application. I'm currently using the following configuration files. foo.service [...
Rene's user avatar
  • 171
6 votes
1 answer
3k views

Print current number of bytes in a pipe

I can create a pipe to transfer information between two programs. I can even use a utility like pv to view progress of total data passing through the pipe. In my case I am using a named pipe. When ...
dtmland's user avatar
  • 508
5 votes
2 answers
5k views

Writing on a FIFO with multiple processes

I need to make a named pipe with mkfifo. For instance: mkfifo mypipe I'm going to have a systemd service (a simple shell script) that read from the pipe and I will write on the same pipe calling ...
mugnozzo's user avatar
  • 153
4 votes
1 answer
4k views

How to read a webcam that is already used by a background capture?

A ffmpeg webcam capture is running in the background. ffmpeg -f video4linux2 -s vga -i /dev/video0 capture.mp4 (1) I am therefore unable to read it with ffplay since the device /dev/video0 is ...
user123456's user avatar
  • 4,918
4 votes
2 answers
7k views

How can I pipe commands to any terminal?

I often use more than one terminal (or terminal emulator) at a time; and while in X I can copy-paste commands, besides not being very practical, it obviously does not work on the real TTY. The first ...
JMCF125's user avatar
  • 1,052
4 votes
1 answer
2k views

/proc/[pid]/fd/[0, 1, 2]: No such file or device - even though file exists

I'm trying to access a process' stdio streams from outside its parent process. I've found the /proc/[pid]/fd directory, but when I try $ cat /proc/[pid]/fd/1 I get a No such file or device error. I ...
J-Cake's user avatar
  • 155
3 votes
0 answers
1k views

Write to stdin of running process on occasion

From time to time I want to send some text to the input of netcat. Netcat will send it then to another netcat process (either on my machine or a local network), but now I am only concerned with the ...
Al.G.'s user avatar
  • 269
3 votes
1 answer
5k views

How make service reading from FIFO socket

So before I take my axe and destroy my Desktop I will try asking here :-) I have a socket activated service named commander.service. Because of simplicity I just want to push bare strings or chars to ...
Lenny's user avatar
  • 33
2 votes
1 answer
2k views

Why stdout won't flush when redirecting input from a fifo?

I have a program that displays a prompt message and waits for the user to input some text. $ program Input a line of text: <aaaa> Some more output. $ Now, I also want to be able to provide ...
Harry's user avatar
  • 812
2 votes
2 answers
1k views

FIFO-based semaphore explanation

I am trying to work on some parallelization of many processes (task send/to be executed on many (let's say hundreds) nodes). I came across this solution: https://unix.stackexchange.com/a/216475 # ...
Jozef Dzurenda's user avatar
2 votes
1 answer
1k views

create several /dev/xconsole files automatically upon boot

I understand from my previous question that the /dev/xconsole file can be created using mkfifo. On my system (Debian Wheezy), /dev/xconsole gets created automatically. I am wondering who creates it (...
Martin Vegter's user avatar
1 vote
1 answer
1k views

Redirect script stdin to file in the background

In order to pass my script's stdin to stdin of a command in an alacritty instance it spawns, I'm trying to redirect it to a file in the background (so that the command can start reading it): t="$(...
OJFord's user avatar
  • 1,884
1 vote
2 answers
4k views

Cheapest way to find the oldest file (recursively) from a directory under heavy load

What is the least expensive way to find the oldest file in a directory, including all directories underneath. Assume directory is backed by SAN and under heavy load. There is concern that "ls" could ...
Robert Christian's user avatar
1 vote
1 answer
2k views

How does a temporary file differs from a pipe? [duplicate]

When one sends data (say stdout) to a temporary file, it is likely that something would be done with that data (the temporary file will be used as stdin for some process), then the temporary file will ...
Arcticooling's user avatar
0 votes
0 answers
33 views

Strange incongruent output for both nc and fifo

I have this exact code: #!/bin/bash gtimeout(){ if type -f gtimeout &> /dev/null; then command gtimeout "$@" else timeout "$@" fi } export -f gtimeout; ...
Alexander Mills's user avatar
0 votes
0 answers
232 views

zsh, zpty: How to read the output of a process after it has exited?

Start some command with zpty: zpty -d x ; zpty x 'echo hi' ; sleep 1 How do I read its output now that it has exited? zpty -r x Returns 2, and this behavior seems expected per the manpage.
HappyFace's user avatar
  • 1,523