Questions tagged [fifo]

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

0
votes
1answer
35 views

How to properly write a string to a named pipe and the difference between echo and printf

Problem: I need to send a command to a named pipe and need to ensure only the command is sent and not any errant or "fat-fingered" characters. Example: I have been using the following: echo "...
1
vote
1answer
18 views

How can I merge two sorted named pipes with uneven sizes?

My question is similar to "Merge two sorted files based on sorting values in the same field" but extending it to named pipes. Say I have two text files with sorted integers and I want to merge them. ...
0
votes
1answer
25 views

Why don't named pipes respect the order at which readers were attached?

I have this test script: #!/usr/bin/env bash fif="foooz"; rm "$fif" ; mkfifo "$fif" ( cat "$fif" | cat && echo "1") & sleep 0.1 ( cat "$fif" | cat && echo "2") & sleep 0....
0
votes
2answers
75 views

Check if named pipe is open for reading

Right now, I have this crappy check to see if a named pipe is being read from: is_named_pipe_being_read() { local named_pipe="$1" echo "unlocked" > "$named_pipe" & pid="$!" #...
2
votes
1answer
33 views

How to write something to named pipe even if there are no readers

I have this little test script: rm fooo | cat mkfifo fooo echo 'bar' > fooo # blocks here echo 'done' I am guessing that because there is nobody reading from the named pipe, that the write call ...
2
votes
1answer
30 views

How to check for presence of named pipe on the file system [duplicate]

I tried using the -f flag to test if a named pipe is present if [[ ! -f "$fifo" ]]; then echo 'There should be a fifo.lock file in the dir.' > /dev/stderr return 0; fi this check does not ...
1
vote
1answer
37 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 ...
6
votes
2answers
136 views

Difference between > and >> when used with a named pipe

Is there any difference between the two redirections in the following code? mkfifo foo echo > foo echo >> foo
0
votes
1answer
39 views

Process exits unexpectedly when sending to a named pipe

I have two processes and one named pipe. One process is actively reading from the pipe, and one process is sending data to the pipe continously. The command that sends to the pipe is the following :...
-1
votes
1answer
50 views

Writing continuously to named pipe

I have a problem that I can't seem to solve involving two named pipes. Basically, I have two processes that I don't have control over. They are communicating via named pipes (mknod pipe p). Process ...
0
votes
0answers
26 views

ssh reverse tunnel with dynamic port for backup over ssh in DMZ

I'd like to do backup over ssh on a server in DMZ, the backup would be executed by a backup server which can ssh to DMZ. I was thinking to use reverse ssh port forwarding with dynamic port, ie. ssh -R ...
0
votes
1answer
36 views

Run program when/instead of writing to FIFO? [closed]

I have a program that writes data every second to a FIFO. Now I want to alter some of this data and write it to another FIFO. What would be the best approach? Can I somehow pipe this directly to my ...
3
votes
1answer
92 views

Make GNU Parallel not delay before executing arguments from STDIN

GNU Parallel, without any command line options, allows you to easily parallelize a command whose last argument is determined by a line of STDIN: $ seq 3 | parallel echo 2 1 3 Note that parallel does ...
2
votes
1answer
76 views

concurrent processing in bash using process expansion, and redirection

Apart from possible races that have to be controlled by using proper synchronisation, it's possible in bash to feed a data source concurrently into multiple pipelines and collect all their outputs ...
1
vote
2answers
39 views

Two named PIPEs (PIPE_in/PIPE_out) connected with `tail -f` | String sent to PIPE_in doesn't reach PIPE_out

1.Create named PIPEs, pipe_in and pipe_out by running: $ mkfifo pipe_in $ mkfifo pipe_out 2.Connect pipe_in to pipe_out: TERM0: $ tail -f pipe_in > pipe_out 3.Send string hello world! to ...
6
votes
3answers
199 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 /...
5
votes
2answers
275 views

grep --exclude option doesn't always skip named pipes

I have a directory that contains, among other files, 3 named pipes: FIFO, FIFO1, and FIFO11. If I try something like grep mypattern * in this directory, grep hangs forever on the named pipes, so I ...
2
votes
0answers
183 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 [...
2
votes
2answers
61 views

Bash: join pipes without deadlock

I want to list a bunch of filenames via find, pipe them through a utility (let's call this util) which outputs a new name for each input name, and then rename each file from the old name to the new. ...
0
votes
1answer
62 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: ...
0
votes
1answer
134 views

How to Pass Multiple Commands to Remote Device via SSHPass [duplicate]

I'm trying to setup a method in which I can run remote tcpdumps on some of my devices, and save the file to my local machine for analysis (I don't want to save the file on the remote device and then ...
3
votes
1answer
297 views

Using exec 3> to keep a named pipe open

The process reading from a named pipe will normally terminate when the process writing to the pipe finishes writing (sends an EOF). In certain situations you may have different processes writing ...
2
votes
0answers
36 views

How to trigger a command after named pipe closes?

How can I execute some command after the named pipe has been readout in other end. I was trying to use trap. But nothing happens. My script is something like below. #!/bin/sh cleanup() { echo "...
0
votes
2answers
100 views

How to let process continue running even after disconnecting ssh?

I have a Linux based router that I’m trying to “control” with a home automation controller. On my automation controller I’m able to utilize a ‘two way strings’ driver to send a string to the Linux ...
0
votes
1answer
94 views

Multiple fifos over SSH

Shell script allow multiple file descriptors (up to 9 for POSIX compliance, but even more for bash): $ install -m 755 /dev/stdin /tmp/test <<\EOF #!/bin/sh echo hi1 >&1 echo hi2 >&...
1
vote
1answer
362 views

How can I stop ffmpeg from quitting when it reaches the end of a named pipe?

I'm using a program which continuously writes MPEG-TS video data to a file while it's running. I'm expecting it to run continuously for many days. I want to use ffmpeg to transcode this video data ...
0
votes
1answer
69 views

How to read screen's named pipe?

For curiosity, I wanted to read a GNU screen session's named pipe. $ screen -ls There is a screen on: 59750.hello (Detached) 1 Socket in /var/run/screen/S-gergely. And indeed there is a ...
2
votes
0answers
62 views

Knowing when bash is done running a command through a FIFO pipe

I'm trying to link a web-based terminal with bash. My current attempt to do so is spawning a shell pointing a FIFO pipe to its input, like this: Terminal 1 $ mkfifo pipe $ bash <> pipe file1 ...
0
votes
1answer
72 views

Pipe to fifo from script

I want to send commands from a script to twinkle (the VOIP software). I thought I could do this with a named pipe so I have created one mkfifo phonecmd If I start twinkle and pipe tail from the ...
2
votes
0answers
87 views

How can I make named pipes atomic or is there an alternative? [duplicate]

Reopen voters: flock() doesn't work on named pipes, this is not a dupe. I was trying to do the following with named pipes: mkfifo example.txt ( printf "456"; printf "abc"; printf "\n"; ) > ...
5
votes
1answer
353 views

How can I know whether writing to a named pipe would block?

I want to write to a named pipe only if it already has a reader. Currently, I'm using timeout to detect whether the attempt to write to the pipe blocked, like so: #! /usr/bin/env bash rm -f pipe ...
0
votes
0answers
453 views

Cleaning/flushing of named pipe

I create FIFO to communicate between unrelated processes. In my project there is no way to break infinite loop in which the program runs. So, I can't unlink the FIFO. I thought that I could remove ...
1
vote
0answers
31 views

Retaining data in a named pipe after an incomplete read access

Prerequisites: $ mkfifo pipe1 If several lines are put into pipe1 $ (echo line 1; echo line 2) > pipe1 all the lines can be read in another terminal by $ cat pipe1 line 1 line 2 So far all ...
0
votes
1answer
22 views

Is it possible to remount a filesystem read-only, if it has open fifos?

If a file is still open for writing on the root file system, for example, the filesystem cannot be remounted read-only for a clean shutdown. At least this is true for regular files. But what about ...
3
votes
2answers
1k 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 ...
0
votes
1answer
275 views

Split output and rejoin again with named pipes on linux

My question is related to https://serverfault.com/questions/171095/how-do-i-join-two-named-pipes-into-single-input-stream-in-linux but with a slightly more convoluted setup. I have three programs, ...
10
votes
3answers
2k 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: $ ...
0
votes
1answer
230 views

using fifo for daemons

While studying from Richard Stevens' book Unix network programming, I came across the following lines that speak about using FIFO between a client and a server. Client processes are started and ...
2
votes
1answer
273 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 ...
0
votes
1answer
493 views

bash: Reading a full record from a fifo

I wish to send a command to process A, from process B, via a FIFO. The command will be a word or a sentence, but wholly contained on a "\n" terminated line - but could, in general, be a multi-line ...
0
votes
1answer
143 views

Linux AIO / io_submit / io_getevents / on fifo (named pipes)

I have to write a lot of data to a pipe. Can I use the Linux calls io_submit/io_getevents for writing to Named Pipes or it is defined only for regular files. I tried finding any document which ...
0
votes
1answer
52 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 ...
1
vote
1answer
460 views

Creating a tarball from named pipes using tar or python's tarfile module

I didn't realize this would be so difficult. I'm just using tar. I have two pieces of data, one's a large payload of pcap data, the other is some additional metadata in the form of a python pickled ...
0
votes
1answer
40 views

Programmatically closing pipeline / exiting [closed]

I have a pipeline like so: tail -n0 -f "${my_input}" | ql_receiver_lock_holder | while read line; do echo "$line" >> "${my_output}"; # xxx: how can I programmatically close the ...
0
votes
2answers
49 views

Avoid overwriting existing named pipe

I have this command: ql_receiver_lock_holder > "${my_named_pipe}" will it overwrite the named pipe if it already exists? Is the best way to avoid overwriting it to simply use this: ...
3
votes
1answer
2k views

Change buffer size of named pipe

I hear that for named pipes, writes that are smaller than about 512bytes are atomic (the writes won't interleave). Is there a way to increase that amount for a specific named pipe? something like: ...
1
vote
1answer
328 views

Read and write to same netcat tcp connection

I have this pipeline: ( tail -f ${named_pipe} | nc localhost ${port} | ql_conditional_release &> "$HOME/debug.log" & disown; ) &> /dev/null so I am reading from the netcat ...
1
vote
1answer
402 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 ...
12
votes
2answers
4k 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 ...
0
votes
1answer
288 views

Process substitution vs FIFO (created by `makefifo`)

As far as I know, process substitution in bash and FIFO (created by mkfifo) are both named pipes. They both seem viable solutions for communication between processes. I was wondering how to decide ...