Questions tagged [coprocesses]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
184 views

Bash coproc with python

I am playing with the coproc of Bash and I am failing to understand something. I started with the following example: Example#1 $ coproc MY_BASH { bash; } [1] 95244 $ echo 'ls -l; echo EOD' >&&...
chemacabeza's user avatar
2 votes
1 answer
3k views

How does bash know about its parent's coprocess in this situation, and why does a shebang line change it?

outer.sh: ls -l /proc/$$/exe coproc cat ./inner.sh kill $! inner.sh: ls -l /proc/$$/exe set | grep COPROC || echo No match found coproc cat kill $! When I run ./outer.sh, this gets printed: ...
Joseph Sible-Reinstate Monica's user avatar
0 votes
1 answer
440 views

Return value vs return status of a coprocess

I don't understand this sentence about Coprocesses in the bash man page: Since the coprocess is created as an asynchronous command, the coproc command always returns success. The return status of a ...
The Quark's user avatar
  • 270
0 votes
0 answers
290 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,612
6 votes
2 answers
697 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
0 answers
317 views

Using coprocess to write a name referenced variable in BASH

I currently try to start background process with coproc and update a name reference variable. My not working code: function updateVariable(){ local -n myVar="${1}" #i=0; while : do ...
kon's user avatar
  • 123
1 vote
0 answers
42 views

Usage of cvlc with coproc

I'm trying to feed to file descriptor .mp3 files the with the dummy interface of vlc, i.e., cvlc, in order to add to a playlist on the fly or override the entire file descriptor with new data (new ....
amosmoses's user avatar
0 votes
1 answer
1k views

Coproc in bash script

I'm trying to do a simple shell script that will make my raspberry's bluetooth discoverable but i'm facing some issues. My raspberry is running Raspbian. Running this through command line works ...
Kamigaku's user avatar
5 votes
2 answers
2k views

Is it possible to have multiple concurrent coprocesses?

The intent of the test script1 below is to start an "outer" coprocess (running seq 3), read from this coprocess in a while-loop, and for each line read, print a line identifying the current iteration ...
kjo's user avatar
  • 15.3k
9 votes
4 answers
5k views

Run command in background with foreground terminal access

I am trying to create a function that can run an arbitrary command, interact with the child process (specifics omitted), and then wait for it to exit. If successful, typing run <command> will ...
John Kugelman's user avatar
1 vote
1 answer
394 views

How does bash coprocess achieve its pipelining?

Note this passage from man bash ( emphasis mine ): Coprocesses A coprocess is a shell command preceded by the coproc reserved word. A coprocess is executed asynchronously in a subshell, as ...
Sergiy Kolodyazhnyy's user avatar
5 votes
2 answers
2k views

Is coproc <command> the same as <command> &? [duplicate]

I have read that $coproc < command > is different from $< command > & in that coproc will execute command in a sub-shell process. But when I tested it, it worked just like $< ...
Tran Triet's user avatar
-3 votes
2 answers
454 views

inter process comunication in bash read commands in multiple background functions

I'm trying to get the following code to read from a main input then read that in one function then be able to send that into the input of another function but i am having trouble getting it to work ...
Clark Kent's user avatar
3 votes
1 answer
397 views

Why does this gawk coprocess hang?

While having a go at Convert date in bash shell, I tried GNU awk's coprocess feature: gawk -F, -v cmd='date +"%Y-%m-%d %H:%M:%S" -f-' '{print $5 |& cmd; cmd |& getline d; $5 = d}1' foo This ...
muru's user avatar
  • 73k
5 votes
1 answer
176 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.8k
117 votes
4 answers
40k views

How do you use the command coproc in various shells?

Can someone provide a couple of examples on how to use coproc?
slm's user avatar
  • 370k