Questions tagged [fifo]

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

Filter by
Sorted by
Tagged with
2 votes
2 answers
136 views

Reading from two fifos in Bash

I'm trying to read from two fifos (read from one, if there's no content read from the other, and if there's no content in neither of both try it again later), but it keeps blocking the process (even ...
user avatar
1 vote
1 answer
65 views

bash IPC using named pipes

Consider the below script #!/usr/bin/bash chan=/tmp/pipe.$$ mkfifo $chan { for x in a b c d e do echo $x > $chan done } & for y in 1 2 3 4 5 do x=$(cat $chan) echo &...
user avatar
  • 4,049
2 votes
1 answer
65 views

FIFO and simple bash parallelization on CentOS

I am having problems adapting a bash script to handle a simple parallel execution from Ubuntu 20.04 to CentOS Linux 8. In the script I spawn multiple "readers" that read a string from a FIFO ...
user avatar
  • 21
0 votes
1 answer
226 views

Writing in the file descriptor of the child process (fd/0)

I'm playing with file descriptors in my CentOS 7 sandbox. In doing so, I noticed an interesting situation. Suppose we've a simple PHP script: $step = 4 * 1024; echo "php started\n"; while (!...
user avatar
2 votes
1 answer
291 views

Bash named pipes, parallel commands and exit status

I'm trying to use a named pipe so I can keep stdout for status output from a long process. I could use stderr for status output, but I'd like to keep that for errors. Here is an example: #!/bin/bash ...
user avatar
  • 328
2 votes
1 answer
46 views

Close all readers of a FIFO once all its input is read?

How can I close all readers of a FIFO once all its input is read? Seems I can only get one of them to close, which keeps my program from finishing. Here's a sample program that works (to test put it ...
user avatar
  • 155
0 votes
0 answers
38 views

parsing concurrent logging from named pipe

I have an application written in C that uses fprintf to stdout/stderr for logging. The output I need is available only through the most verbose setting so the log file quickly becomes huge. My ...
user avatar
1 vote
1 answer
105 views

Detecting sound / silence on a sox pipe?

I am trying to keep a sox pipe input from a sound card open and execute a player commend only when there is sound in the pipe (without killing the pipe or using a file). This could be easily achieved ...
user avatar
  • 11
10 votes
2 answers
3k 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 ...
user avatar
-1 votes
1 answer
122 views

named pipe in bash script

I have a C program to experiment with signals (./signal). It processes the standard input, exits when reading a 'q' and reacts to signals. I would like to test it with a bash script using a named pipe ...
user avatar
  • 415
5 votes
1 answer
404 views

How should I set up a systemd service to auto-start a server and let me pass commands to it?

Goal: I'm trying to get a Minecraft server to run on computer boot with systemd on Fedora. I have a few self-imposed criteria that I need to meet to be able to properly manage my server(s): It has to ...
user avatar
  • 55
-1 votes
2 answers
81 views

Do any shells generalize the notion of pipes to multiple parallel pipelines? Would supporting it require changes to the OS kernel?

Quite often, when working on the command line, I find myself specifying the same operation on a bunch of different instances specified by some input stream, and then wanting to recombine their outputs ...
user avatar
2 votes
2 answers
264 views

Can we use $PIPESTATUS with the tee (or pee) command?

In my bash scripts, I often use pipes and would like to know which stage of the pipe was causing the problem in case of errors. The basic structure of such snippets is: #!/bin/bash ProduceCommand 2&...
user avatar
  • 2,213
1 vote
0 answers
187 views

Write firmware over /dev/ttyUSB0 to embedded device

I'm using the last example in: this post I keep getting wctx:file length=0 after the sz command. I'm actually opening the serial connection with minicom Minicom is botching the transfer. So, after I ...
user avatar
  • 129
2 votes
1 answer
152 views

Can named pipes/FIFOs be used in a "cyclic" manner together with `tee`?

Why does the last line in this script gets stuck? #!/usr/bin/env bash trap 'rm -f numbers' EXIT mkfifo numbers decrement() { while read -r number; do echo "debug: $number" >&...
user avatar
0 votes
0 answers
28 views

Using a ‘permanent’ named pipe as input to a program [duplicate]

I’ll admit I don’t fully understand named pipes. I’ve read everything I can about them, but I’m still not sure how to keep one ‘open’ for repeated use. Basically, I want to use a named pipe as input ...
user avatar
  • 101
1 vote
1 answer
37 views

Bash: Difference between paste command with Command Substiution vs. FIFO FDs

I'm just trying to understand why when I use a couple FIFO FDs in a paste command I get a 'Broken Pipe' but when I use Command Substitution everything is all good. A little background: I have a need ...
user avatar
1 vote
0 answers
45 views

bash script to lazy tar to fifo as files arrive

Here's the hypothetical scenario: I have an archival process where files are showing up and I append them to tar, and then the tar gets zipped. Something like this: while sleep 1 ; do new_files=&...
user avatar
  • 965
1 vote
1 answer
85 views

Using named pipe to get process substitution exit codes

I have a script with a fairly complex command with several process substitutions and I need to get the exit codes from the commands in the process substitutions. I'm trying to do so via a named pipe ...
user avatar
  • 2,127
4 votes
1 answer
66 views

What's wrong with this branched data flow using `tee`, fifos, and `paste`?

In the spirit of this question, I want to create a branched data flow from a single source: cmd1 ──> tee ──────────────> │    ├─────> cmd2 ─────> │ cmd4       └─────&...
user avatar
0 votes
0 answers
45 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.
user avatar
  • 1,295
0 votes
2 answers
613 views

How can I read from named pipe line by line and exit?

I have the following bash script that I'd like to use as a fuzzy file opener. I create a fifo, spawn a new terminal with fzf running and redirect fzf's output to the fifo. I then call a function that ...
user avatar
  • 347
2 votes
1 answer
2k views

Can multiple processes open a named pipe?

I'm creating a process that is going to publish data via a named pipe and I envision there being multiple subscribers. Is there some way my process can Tee off the named pipe it is wring too each time ...
user avatar
  • 123
5 votes
2 answers
335 views

coproc and named pipe behaviour under command substitution

I have a requirement to make a function in a zsh shell script, that is called by command substitution, communicate state with subsequent calls to the same command substitution. Something like C's ...
user avatar
  • 165
-1 votes
1 answer
122 views

Send signal to paused parent process and guarantee that it will arrive AFTER the parent pauses

I have this kind of pseudo-code and i'm wishing to know what I must change in order to guarantee that the signal send to the parent will indeed arrive after that the parent pauses. int main() { ...
user avatar
0 votes
0 answers
199 views

Program execution hanging when trying to use fgetc() over a file stream returned by fdopen() function

I'm making a program where I'm creating 3 sets of fifos (named pipes) to comunicate over processes, I have found where the execution is hanging but not why, and now I'm stuck. I have identified that ...
user avatar
1 vote
2 answers
505 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 # ...
user avatar
2 votes
1 answer
70 views

Pipes and graphics

When developing a program (in C or Python, say), I often write debug messages to see whether my program behaves as intended. On Linux, such text messages can be handled in varied and flexible ways ...
user avatar
  • 121
1 vote
2 answers
141 views

Ordering output when two subshells write to stdout

I have a command of the below form input | tee >(subshell) | mainshell Both subshell and mainshell writes to stdout. So their output is not synchronised. E.g. echo "Hello\nWorld" | tee &...
user avatar
  • 4,049
1 vote
1 answer
454 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="$(...
user avatar
  • 1,608
1 vote
1 answer
647 views

The memory dump of a process by using GDB inside a bash script - errors, problems

I want to dump some program's memory segment to a file. Because the working time of my program is milliseconds, I use named pipe to stop its execution and dump its memory content by gdb meanwhile. The ...
user avatar
  • 3,730
4 votes
1 answer
1k 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 ...
user avatar
  • 143
0 votes
0 answers
56 views

FIFO sometimes requires two writes to satisfy read

I found some baffling behavior on Ubuntu 18.04.4 LTS. In one terminal, I'd like to write a private key to a FIFO. $ mkfifo /tmp/fifo $ chmod o-rwx /tmp/fifo $ chmod g-rwx /tmp/fifo $ cat id_rsa > /...
user avatar
3 votes
0 answers
314 views

How to pipe all output streams to another process?

Take the following Bash script 3-output-writer.sh: echo A >&1 echo B >&2 echo C >&3 Of course when ran as . 3-output-writer.sh it gets the error 3: Bad file descriptor, because ...
user avatar
1 vote
1 answer
348 views

Trap SIGPIPE upon writing to FIFO

These are the steps to reproduce the problem. writer: #!/bin/bash trap 'echo NoReader!' PIPE cat > fifo Open two terminals. I will denote them by the >T1< and >T2< headers below, and ...
user avatar
  • 17.4k
1 vote
0 answers
119 views

Is it possible to have SSH display an "active" banner, by running a script to generate the banner each time, rather than read a static file

The sshd_config banner directive reads a file, but I want it to run a script, and ideally personalize the banner to the user... is this possible with ssh, or is there a way I can create a device file ...
user avatar
0 votes
2 answers
91 views

how to redirect a pending firefox download to a named pipe?

My router provides a live capture in an fancy web interface full of authentication and JS stuff. So if I capture the traffic firefox download a pcap file til I stop the job. I want to be able to see ...
user avatar
  • 11
1 vote
1 answer
1k views

mkfifo with all permissions still errors with permissions denied for other user

Ubunbu 20.04 fifo pipe is created via a bash script from user A with: [[ ! -p $fifopath ]] && mkfifo $fifopath -m0777 This creates: prwxrwxrwx 1 A A 0 May 25 00:40 /tmp/somefifo Then, if ...
user avatar
  • 111
2 votes
0 answers
149 views

Combine mkfifo and cp --reflink to append files without copying data

I have huge files {0..9}.bin which I want concatenate into out.bin. I don't need the original files afterwards. So I was wondering, if this is possible by only modifying the filesystem index without ...
user avatar
1 vote
1 answer
307 views

Named pipe stdout redirection instead of numeric file descriptor

So I was fiddling around for hours now. I have the following problem: I am running a command (node.js script) that writes to stdout via process.stdout.write. It is interactive and at one point it ...
user avatar
1 vote
2 answers
60 views

How to read server stdout and continue only after message is outputted

Say I have a simple Node.js server like: const http = require('http'); const server = http.createServer((req,res) => res.end('foobar')) server.listen(3000, () => { console.log(JSON....
user avatar
1 vote
0 answers
103 views

Piping two audio FIFOs simultaneously, where one may not have data but takes priority, into a single FIFO output

I have a snapcast audio server, which is configured to have three audio streams (fifos): music, broadcast, and output. My speakers play the audio from the output stream, and my music players pipe ...
user avatar
0 votes
1 answer
202 views

Command to create/connect to an I/O stream?

So I'm trying to connect to a (Lua) debugger embedded in a program by redirecting the I/O. Currently I create a pair of FIFOs for the read and write streams and connect to them using cat /tmp/...
user avatar
  • 101
3 votes
0 answers
938 views

Looking at the kernel logs to see if there is something wrong with my machine

My ubuntu machine slowed down, I was following these instructions: https://askubuntu.com/questions/21632/slow-response-and-system-lag the slowness I see is pretty uniform, and there's definitely a ...
user avatar
0 votes
0 answers
64 views

Piping Multiple stdouts to Python program?

I have a program that prints in stdout and I'd like multiple instances of it where each instance's stdout is piped to a sed and then the result(of three such sed) piped to a python program. I'm doing ...
user avatar
0 votes
1 answer
66 views

What is this code actually doing?

While doing a CTF challenge on a platform, I needed a reverse shell but couldn't get one working so I looked at the processes and found one reverse shell code: rm /tmp/m;mkfifo /tmp/m;cat /tmp/m|/bin/...
user avatar
  • 301
2 votes
1 answer
3k views

Why is `BrokenPipeError` dependent on the size of the piped stream?

The following script raises BrokenPipeError: [Errno 32] Broken pipe, when piped to a command like head (unless the number of lines to head exceeds the number of lines printed by the Python script). ...
user avatar
  • 1,749
2 votes
1 answer
48 views

Multiple Tracing Events Readers

Question Does the tracing pipes in Linux, for tracing events, accepts simultaneous readers? Context I am trying to get traces from the RAS subsystem while running some benchmarks. This subsystem ...
user avatar
0 votes
1 answer
2k views

Named pipe buffer after process end

I am creating named pipes in Ubuntu 18 and 16 environments in C language using gcc as compiler (mkfifo() and open()). One of the things I noticed that the named pipes remain in the filesystem after ...
user avatar
1 vote
1 answer
231 views

GNU Parallel Python Semaphore

I have a Python script parallelized through GNU parallel which finds a certain result which I would like to output to a file, which I currently do through standard Python file IO. The issue is that I ...
user avatar

1
2 3 4 5