Questions tagged [coprocesses]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
57 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: ...
user avatar
0 votes
0 answers
51 views

Zsh: bind a key to run another command while a zsh script is in foreground

Zsh keybindings seem to work only when the shell is waiting for a command after the prompt. When a zsh script is launched, it cares about reading inputs only when a command like read is encountered, ...
user avatar
0 votes
1 answer
128 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 ...
user avatar
  • 234
0 votes
0 answers
44 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
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
0 votes
0 answers
108 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 ...
user avatar
  • 113
1 vote
0 answers
23 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 ....
user avatar
0 votes
1 answer
674 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 ...
user avatar
4 votes
2 answers
1k 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 ...
user avatar
  • 13k
8 votes
4 answers
4k 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 ...
user avatar
0 votes
1 answer
265 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 ...
user avatar
3 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 $< ...
user avatar
-3 votes
2 answers
393 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 ...
user avatar
3 votes
1 answer
305 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 ...
user avatar
  • 64.3k
5 votes
1 answer
167 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 ...
user avatar
  • 26.3k
105 votes
4 answers
34k views

How do you use the command coproc in various shells?

Can someone provide a couple of examples on how to use coproc?
user avatar
  • 346k