Questions tagged [fifo]

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

Filter by
Sorted by
Tagged with
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
10 views

Simulating control characters such as "H key" , "UP arrow key" , etc

I have a Device 1 which has debian OS installed on it. I access the serial console of it through other device i.e. Device 2 . I have scripts on the device 2 which will uninstall and install different ...
Anubhav Rai's user avatar
0 votes
1 answer
157 views

Continuously polling a named (FIFO) pipe

I am trying to use a named pipe to monitor the activity of a running shell script. That shell script will write to the pipe that it has "Started" processing. When it has completed ...
nbmlane's user avatar
0 votes
0 answers
48 views

Simultaneous input from fifo and terminal in bash

I am running ffmpeg inside a script and I want to be able to quit ffmpeg either by pressing 'q' in the terminal it's running in (default behaviour) or by inputting 'q' into a fifo file, whichever I ...
Mouse'nKeyboard's user avatar
1 vote
1 answer
199 views

send (alsa) audio via network via UDP

This to my understanding records mono in wav format for 300 seconds to a named pipe called "mic_rec" rec arecord -D hw:4,0 -d 300 -f cd -t wav -c 1 mic_rec And this sends whatever it finds ...
Daniel's user avatar
  • 153
1 vote
1 answer
63 views

Allow a sudo sub process to update Zenity running as original user

A script run by user 'staffer' runs zenity --progress. It then calls sudo -u adminBod adminScript (and the STDOUT and STDERR are collected to logger) I want adminScript which is running as adminBod to ...
artfulrobot's user avatar
  • 2,849
0 votes
1 answer
138 views

Filtering log statements before they're written

I have an application I need to run in verbose mode to get the information I'm interested in. This produces an enormous log file that is <1% interesting for my requirements.I want some way of ...
Stephen Boston's user avatar
0 votes
0 answers
29 views

How to implement lossy buffering? [duplicate]

I want to capture log data and analyze it in real time. Specifically the output of mysql's slow query log. However this needs to be minimally invasive. Pointing the source to a FIFO rather than a ...
symcbean's user avatar
  • 5,203
2 votes
2 answers
58 views

Process not showing under ps -ef | grep command

I ran a command in shell cat >my1.fifo & and when trying to find the PID it is not showing under ps -ef | grep my1.fifo
Anubhav Rai's user avatar
0 votes
0 answers
50 views

Not able to give input to my telnet connection through fifo file if I run it from script

I have a python script which is sending commands to a fifo file through this command. printf "command" > my1.fifo An another process (telnet login) is taking input from this my1.fifo ...
Anubhav Rai's user avatar
0 votes
1 answer
297 views

Grant Permission to Run Process with FIFO

I am trying to run a program that sets its own scheduler policy to sched_FIFO, but it errors out saying operation not permitted. If I run it with sudo then it succeeds, but I want to reduce the ...
Chad's user avatar
  • 73
3 votes
2 answers
843 views

How do I attach a bash shell to a named pipe?

Let’s say I have two containers X and Y (two containers in the same Kubernetes pod, actually) that share a volume. On that volume is a named pipe /foo that I want attached to a bash process on ...
koehn's user avatar
  • 163
0 votes
2 answers
250 views

when read buffer size is 2048, it work , but buffer size is 48 or other number, write call will be blocked, why?

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/select.h> #include <fcntl.h> #include <unistd.h> int main(int argc, char* argv[]){ if(...
zhenfei ren's user avatar
1 vote
1 answer
639 views

Usage of named pipe as data source for netcat

I want to use netcat as a TCP-server that reads data from a named pipe. For that I did the following: Step 1. Created a pipe and the server that uses it as a source mkfifo /tmp/all.pipe nc -k -l 8080 &...
ka3ak's user avatar
  • 1,235
3 votes
4 answers
157 views

Protect against vanishing output redirection targets

I have a daemon running on an embedded Linux device with its output redirected to the serial console: my_daemon > /dev/ttyS0 But now if a user exits the shell running on the serial interface then ...
phk's user avatar
  • 5,893
1 vote
1 answer
161 views

Process (mplayer) doesn't read from named pipe when started from webserver (lighttpd)

tl;dr $ sudo -u www-data mplayer -slave -input file=/srv/mplayer.fifo -playlist /srv/list & $ lsof /srv/mplayer.fifo | tail +2 mplayer 21059 www-data 4u FIFO 179,2 0t0 2359331 /srv/...
steffen's user avatar
  • 121
2 votes
2 answers
809 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 ...
Roger Miranda Perez's user avatar
2 votes
1 answer
888 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 &...
balki's user avatar
  • 4,367
2 votes
0 answers
197 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 ...
Sine's user avatar
  • 21
0 votes
1 answer
1k 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 (!...
novascriptum's user avatar
2 votes
1 answer
987 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 ...
A. Que's user avatar
  • 583
3 votes
1 answer
596 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 ...
rutchkiwi's user avatar
  • 165
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
-1 votes
1 answer
541 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 ...
z32a7ul's user avatar
  • 415
5 votes
1 answer
1k 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 ...
Riley's user avatar
  • 55
0 votes
2 answers
125 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 ...
reinierpost's user avatar
2 votes
2 answers
964 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&...
Binarus's user avatar
  • 3,230
1 vote
0 answers
815 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 ...
Brian's user avatar
  • 168
2 votes
1 answer
325 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" >&...
Ionuț G. Stan's user avatar
0 votes
0 answers
29 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 ...
tjcaul's user avatar
  • 101
1 vote
1 answer
62 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 ...
Wafflemann's user avatar
1 vote
0 answers
106 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=&...
galets's user avatar
  • 1,045
1 vote
1 answer
193 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 ...
Harry Muscle's user avatar
  • 2,477
4 votes
1 answer
76 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       └─────&...
Sasgorilla's user avatar
0 votes
0 answers
234 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,533
0 votes
2 answers
2k 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 ...
noibe's user avatar
  • 387
2 votes
1 answer
4k 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 ...
Nick's user avatar
  • 143
6 votes
2 answers
626 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 ...
Phil's user avatar
  • 175
0 votes
1 answer
482 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() { ...
Dacaramo's user avatar
0 votes
0 answers
354 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 ...
Dacaramo's user avatar
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
126 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 ...
Erik Aas's user avatar
  • 121
1 vote
2 answers
261 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 &...
balki's user avatar
  • 4,367
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
1 answer
1k 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 ...
MiniMax's user avatar
  • 4,043
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
0 votes
0 answers
172 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 > /...
sweetjonnie's user avatar
3 votes
0 answers
648 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 ...
Sinus the Tentacular's user avatar
1 vote
1 answer
690 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 ...
Quasímodo's user avatar
  • 18.7k
1 vote
0 answers
201 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 ...
James Lewis's user avatar

1
2 3 4 5